summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@thoughtworks.com>2014-10-15 14:53:58 +0200
committerBruno Wagner <bwagner@thoughtworks.com>2014-10-15 14:53:58 +0200
commitb829fa5267060528469e70d7d5861450020100d5 (patch)
treef4d0f3bbff1002cf921ce56428ae4d753bf111de
parentac3ea5d3838b98b07d182d71f2f3d9f270b5d274 (diff)
Moved input mail from dict to input mail instead of floating elsewhere
-rw-r--r--service/pixelated/adapter/pixelated_mail.py24
-rw-r--r--service/test/unit/user_agent_test.py1
2 files changed, 10 insertions, 15 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py
index f701e648..6be2e5bf 100644
--- a/service/pixelated/adapter/pixelated_mail.py
+++ b/service/pixelated/adapter/pixelated_mail.py
@@ -46,10 +46,6 @@ class InputMail:
'body': self.body
}
- @staticmethod
- def from_dict(mail_dict):
- return input_mail_from_dict(mail_dict)
-
@property
def _mime_multipart(self):
if self._mime:
@@ -148,6 +144,16 @@ class InputMail:
mime_multipart['From'] = PixelatedMail.from_email_address
return mime_multipart.as_string()
+ @staticmethod
+ def from_dict(mail_dict):
+ input_mail = InputMail()
+ input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}
+ input_mail.headers['Date'] = pixelated.support.date.iso_now()
+ input_mail.body = mail_dict.get('body', '')
+ input_mail.tags = set(mail_dict.get('tags', []))
+ input_mail.status = set(mail_dict.get('status', []))
+ return input_mail
+
class PixelatedMail:
@@ -287,13 +293,3 @@ class PixelatedMail:
'security_casing': self.security_casing,
'body': self.body
}
-
-
-def input_mail_from_dict(mail_dict):
- input_mail = InputMail()
- input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}
- input_mail.headers['Date'] = pixelated.support.date.iso_now()
- input_mail.body = mail_dict.get('body', '')
- input_mail.tags = set(mail_dict.get('tags', []))
- input_mail.status = set(mail_dict.get('status', []))
- return input_mail
diff --git a/service/test/unit/user_agent_test.py b/service/test/unit/user_agent_test.py
index 49a70dd6..9b890a04 100644
--- a/service/test/unit/user_agent_test.py
+++ b/service/test/unit/user_agent_test.py
@@ -41,7 +41,6 @@ class UserAgentTest(unittest.TestCase):
pixelated.user_agent.draft_service = self.draft_service
pixelated.user_agent.search_engine = self.search_engine
self.input_mail = None
- pixelated.adapter.pixelated_mail.input_mail_from_dict = lambda x: self.input_mail
def tearDown(self):
unstub()