summaryrefslogtreecommitdiff
path: root/py-fake-service
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-09-05 10:18:05 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-09-05 10:18:05 +0200
commit41e76814be86ac45190c2ace1d02fdd827d6c88e (patch)
treedf09dbc12714e9e4900c56dab2a0cd0bef44070d /py-fake-service
parent8e653650300948f9bfd91619795ac840d52e73a5 (diff)
Fixed functional tests.
Diffstat (limited to 'py-fake-service')
-rw-r--r--py-fake-service/app/adapter/contacts.py2
-rw-r--r--py-fake-service/app/adapter/mail.py2
-rw-r--r--py-fake-service/app/adapter/mail_service.py10
-rw-r--r--py-fake-service/app/pixelated_user_agent.py2
-rw-r--r--py-fake-service/features/steps/compose.py2
5 files changed, 12 insertions, 6 deletions
diff --git a/py-fake-service/app/adapter/contacts.py b/py-fake-service/app/adapter/contacts.py
index f241de98..19debdf1 100644
--- a/py-fake-service/app/adapter/contacts.py
+++ b/py-fake-service/app/adapter/contacts.py
@@ -22,7 +22,7 @@ class Contacts:
self.contacts = []
def add(self, mbox_mail):
- contact = mbox_mail.get('From')
+ contact = mbox_mail.from_addr
self.contacts.append(Contact(contact))
def search(self, query):
diff --git a/py-fake-service/app/adapter/mail.py b/py-fake-service/app/adapter/mail.py
index a18f6276..d2ae5789 100644
--- a/py-fake-service/app/adapter/mail.py
+++ b/py-fake-service/app/adapter/mail.py
@@ -71,7 +71,7 @@ class Mail:
def _get_headers(self, mbox_mail):
headers = {}
- headers['from'] = mbox_mail.get('From')
+ headers['from'] = mbox_mail.from_addr
headers['to'] = [mbox_mail.get('To')]
headers['subject'] = mbox_mail.get('Subject')
headers['date'] = datetime.fromtimestamp(
diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py
index a422ad9a..2825af9d 100644
--- a/py-fake-service/app/adapter/mail_service.py
+++ b/py-fake-service/app/adapter/mail_service.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import os
+import re
import mailbox
from tagsset import TagsSet
@@ -41,9 +42,14 @@ class MailService:
def _create_message_from_file(self, filename):
data = self._read_file(filename)
+ return self.create_message_from_string(data, filename)
+
+ def create_message_from_string(self, data, filename=None):
if data.startswith('From '):
- msg = mailbox.mbox(filename).popitem()[1]
- msg.from_addr = msg.get_from()
+ msg = mailbox.mboxMessage(data)
+ from_addr = re.sub(r"^From ", "", msg.get_unixfrom())
+ msg.from_addr = from_addr
+ msg.set_from(from_addr)
else:
msg = mailbox.Message(data)
msg.from_addr = msg.get('From')
diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py
index c500dd08..a3ba40b1 100644
--- a/py-fake-service/app/pixelated_user_agent.py
+++ b/py-fake-service/app/pixelated_user_agent.py
@@ -28,7 +28,7 @@ MEDIUM_TAGGED_URL = 'https://static.wazokazi.is/py-mediumtagged.tar.gz'
client = None
converter = None
account = None
-loaded = True
+loaded = False
mail_service = MailService()
diff --git a/py-fake-service/features/steps/compose.py b/py-fake-service/features/steps/compose.py
index 743d10c4..24c2e679 100644
--- a/py-fake-service/features/steps/compose.py
+++ b/py-fake-service/features/steps/compose.py
@@ -44,7 +44,7 @@ def choose_impl(context, recipients_field, to_type):
recipients_element.find_element_by_css_selector(
'.tt-input'
).send_keys(to_type)
- wait_until_element_is_visible_by_locator(context, (By.CLASS_NAME, 'tt-dropdown-menu'))
+ wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '.tt-dropdown-menu div div'))
browser.find_element_by_css_selector('.tt-dropdown-menu div div').click()
@then("for the '{recipients_field}' field I type '{to_type}' and chose the first contact that shows")