summaryrefslogtreecommitdiff
path: root/py-fake-service
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-08-14 18:05:37 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-08-14 18:06:06 -0300
commitea88d617a0d6a942850922664590f80d32de7d87 (patch)
tree292c9616a2ab5c6f99215bc9b0c24c7b39bd5416 /py-fake-service
parent2ee1f78a90fdb47844c8d200ede64169a56e5cbc (diff)
Revert "Enable fake server to correctly serve html emails"
This reverts commit dde0dc6bb735cebe946c6fd8c5d7c8cfd6028cc8.
Diffstat (limited to 'py-fake-service')
-rw-r--r--py-fake-service/app/adapter/mail.py15
-rw-r--r--py-fake-service/app/adapter/mail_service.py14
2 files changed, 14 insertions, 15 deletions
diff --git a/py-fake-service/app/adapter/mail.py b/py-fake-service/app/adapter/mail.py
index 5e0483fc..1cbe065f 100644
--- a/py-fake-service/app/adapter/mail.py
+++ b/py-fake-service/app/adapter/mail.py
@@ -18,7 +18,7 @@ class Mail:
mail.draft_reply_for = mail_json.get('draft_reply_for', 0)
return mail
-
+
def __init__(self, mbox_mail=None, ident=None):
if mbox_mail:
self.header = self._get_headers(mbox_mail)
@@ -31,14 +31,11 @@ class Mail:
def _get_body(self, message):
if message.is_multipart():
- boundary = '--{boundary}'.format(boundary= message.get_boundary().strip())
- body_parts = [x.as_string() for x in message.get_payload()]
-
- body = boundary + '\n'
- body += '{boundary}\n'.format(boundary=boundary).join(body_parts)
- body += '{boundary}--\n'.format(boundary=boundary)
+ boundary = message.get_boundary()
+ start_boundary = '--'+boundary
+ join_boundary = start_boundary+'\n'
- return body
+ return join_boundary + join_boundary.join([x.as_string() for x in message.get_payload()]) + start_boundary+ '--'
else:
return message.get_payload()
@@ -63,7 +60,7 @@ class Mail:
def _get_tags(self, mbox_mail):
return mbox_mail.get('X-TW-Pixelated-Tags').split(', ')
-
+
@property
def subject(self):
return self.header['subject']
diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py
index 41195c0a..7c2570f9 100644
--- a/py-fake-service/app/adapter/mail_service.py
+++ b/py-fake-service/app/adapter/mail_service.py
@@ -16,10 +16,12 @@ class MailService:
def load_mailset(self):
mbox_filenames = [filename for filename in os.listdir(self.MAILSET_PATH) if filename.startswith('mbox')]
- boxes = (mailbox.mbox(os.path.join(self.MAILSET_PATH, mbox)) for mbox in mbox_filenames)
+ boxes = (mailbox.mbox(os.path.join(self.MAILSET_PATH, mbox)) for mbox in mbox_filenames)
for box in boxes:
message = box.popitem()[1]
+ if message.is_multipart():
+ continue
self.mailset.add(message)
self.tagsset.add(message)
self.contacts.add(message)
@@ -47,13 +49,13 @@ class MailService:
def update_tags_for(self, mail_id, new_tags):
mail = self.mail(mail_id)
-
+
new_tags_set = set(new_tags)
old_tags_set = set(mail.tags)
- increment_set = new_tags_set - old_tags_set
+ increment_set = new_tags_set - old_tags_set
decrement_set = old_tags_set - new_tags_set
-
+
map(lambda x : self.tagsset.increment_tag_total_count(x), increment_set)
map(lambda x : self.tagsset.decrement_tag_total_count(x), decrement_set)
@@ -69,8 +71,8 @@ class MailService:
def save_draft(self, mail):
mail = self.mailset.add_draft(Mail.from_json(mail))
return mail.ident
-
-
+
+
def update_draft(self, mail):
mail = Mail.from_json(mail)
self.mailset.update(mail)