diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-09-05 10:18:05 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-09-05 10:18:05 +0200 |
commit | 41e76814be86ac45190c2ace1d02fdd827d6c88e (patch) | |
tree | df09dbc12714e9e4900c56dab2a0cd0bef44070d /py-fake-service/app/adapter | |
parent | 8e653650300948f9bfd91619795ac840d52e73a5 (diff) |
Fixed functional tests.
Diffstat (limited to 'py-fake-service/app/adapter')
-rw-r--r-- | py-fake-service/app/adapter/contacts.py | 2 | ||||
-rw-r--r-- | py-fake-service/app/adapter/mail.py | 2 | ||||
-rw-r--r-- | py-fake-service/app/adapter/mail_service.py | 10 |
3 files changed, 10 insertions, 4 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') |