summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-12-03 13:53:52 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-12-03 15:01:38 +0100
commit81140d851bed8c1c90f739510ff059db698b4f79 (patch)
tree748881f8dfd3199980b971c32e36773a73cdd0e4
parentc05fe2f7ae1b2d224718b21c38b4173b0ac7fd66 (diff)
Moved mail.as_dict to PixelatedMail.
- currently it only works for this class.
-rw-r--r--service/pixelated/adapter/mail.py27
-rw-r--r--service/test/unit/controllers/mails_controller_test.py2
2 files changed, 14 insertions, 15 deletions
diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py
index eedc8242..472bdad4 100644
--- a/service/pixelated/adapter/mail.py
+++ b/service/pixelated/adapter/mail.py
@@ -25,8 +25,7 @@ from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from pycryptopp.hash import sha256
-
-class Mail:
+class Mail(object):
@property
def to(self):
return self.headers['To']
@@ -73,18 +72,6 @@ class Mail:
def _get_chash(self):
return sha256.SHA256(self.raw).hexdigest()
- def as_dict(self):
- return {
- 'header': {k.lower(): v for k, v in self.headers.items()},
- 'ident': self.ident,
- 'tags': list(self.tags),
- 'status': list(self.status),
- 'security_casing': self.security_casing,
- 'body': self.body,
- 'mailbox': self.mailbox_name.lower(),
- 'attachments': self.parts['attachments'] if self.parts else []
- }
-
class InputMail(Mail):
FROM_EMAIL_ADDRESS = None
@@ -319,3 +306,15 @@ class PixelatedMail(Mail):
@property
def encrypted(self):
return self.hdoc.content["headers"].get("OpenPGP", None) is not None
+
+ def as_dict(self):
+ return {
+ 'header': {k.lower(): v for k, v in self.headers.items()},
+ 'ident': self.ident,
+ 'tags': list(self.tags),
+ 'status': list(self.status),
+ 'security_casing': self.security_casing,
+ 'body': self.body,
+ 'mailbox': self.mailbox_name.lower(),
+ 'attachments': self.parts['attachments'] if self.parts else []
+ }
diff --git a/service/test/unit/controllers/mails_controller_test.py b/service/test/unit/controllers/mails_controller_test.py
index 93748de9..6d566c83 100644
--- a/service/test/unit/controllers/mails_controller_test.py
+++ b/service/test/unit/controllers/mails_controller_test.py
@@ -115,7 +115,7 @@ class TestMailsController(unittest.TestCase):
def _successfuly_send_mail(self, ident, mail):
sent_mail = mock()
- mail.mailbox_name = 'TRASH'
+ sent_mail.mailbox_name = 'TRASH'
sent_mail.as_dict = lambda: self.input_mail.json
return sent_mail