summaryrefslogtreecommitdiff
path: root/py-fake-service/app/adapter/mail_service.py
diff options
context:
space:
mode:
authorBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-09-03 18:05:39 -0300
committerBruno Wagner Goncalves <bwagner@thoughtworks.com>2014-09-03 18:06:06 -0300
commitc54674c20aa9bd746d967044ac8cd29788d87f93 (patch)
tree568372a083a415555ffc4faa3d82de7f273d4a13 /py-fake-service/app/adapter/mail_service.py
parent2da2783e2ee984d37b66807c57b1ae9d41750ff4 (diff)
The mailset is not automatically loaded on startup, you can use an csv file as mailset
Diffstat (limited to 'py-fake-service/app/adapter/mail_service.py')
-rw-r--r--py-fake-service/app/adapter/mail_service.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py
index 5c3a6d78..a422ad9a 100644
--- a/py-fake-service/app/adapter/mail_service.py
+++ b/py-fake-service/app/adapter/mail_service.py
@@ -49,14 +49,20 @@ class MailService:
msg.from_addr = msg.get('From')
return msg
+ def _create_message_from_string(self, data):
+ return mailbox.Message(data)
+
def load_mailset(self):
mbox_filenames = [
filename
for filename in os.listdir
(self.MAILSET_PATH) if filename.startswith('mbox')]
messages = (self._create_message_from_file(os.path.join(self.MAILSET_PATH, mbox))
- for mbox in mbox_filenames)
+ for mbox in mbox_filenames)
+
+ self.index_messages(messages)
+ def index_messages(self, messages):
for message in messages:
self.mailset.add(message)
self.tagsset.add(message)