diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-12 18:49:58 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-12 18:50:21 -0300 |
commit | 55041fb165745ee34b14277dbfd694c11f0b7be9 (patch) | |
tree | ac3ced4dfff37081dfdee92d8bfea6926a546742 /py-fake-service | |
parent | 8e0c0485e7c0fd1076291e1a07397726b46ab66e (diff) |
adding reply draft for to py-fake-service
Diffstat (limited to 'py-fake-service')
-rw-r--r-- | py-fake-service/app/adapter/mail.py | 4 | ||||
-rw-r--r-- | py-fake-service/app/adapter/mail_service.py | 3 | ||||
-rw-r--r-- | py-fake-service/app/adapter/mailset.py | 7 | ||||
-rw-r--r-- | py-fake-service/app/pixelated_user_agent.py | 6 |
4 files changed, 16 insertions, 4 deletions
diff --git a/py-fake-service/app/adapter/mail.py b/py-fake-service/app/adapter/mail.py index 242501c8..8116129d 100644 --- a/py-fake-service/app/adapter/mail.py +++ b/py-fake-service/app/adapter/mail.py @@ -10,11 +10,12 @@ class Mail: mail = Mail() mail.header = mail_json['header'] mail.header['date'] = datetime.now().isoformat() - mail.ident = mail_json['ident'] or 0 + mail.ident = mail_json.get('ident', 0) mail.body = mail_json['body'] mail.tags = mail_json['tags'] mail.security_casing = {} mail.status = [] + mail.draft_reply_for = mail_json.get('draft_reply_for', 0) return mail @@ -26,6 +27,7 @@ class Mail: self.tags = self._get_tags(mbox_mail) self.security_casing = {} self.status = self._get_status() + self.draft_reply_for = -1 def _get_status(self): status = [] diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py index 815d3dc4..7c2570f9 100644 --- a/py-fake-service/app/adapter/mail_service.py +++ b/py-fake-service/app/adapter/mail_service.py @@ -78,5 +78,6 @@ class MailService: self.mailset.update(mail) return mail.ident - + def draft_reply_for(self, mail_id): + return self.mailset.find(draft_reply_for=mail_id) diff --git a/py-fake-service/app/adapter/mailset.py b/py-fake-service/app/adapter/mailset.py index b59959a7..0b55bdc2 100644 --- a/py-fake-service/app/adapter/mailset.py +++ b/py-fake-service/app/adapter/mailset.py @@ -39,4 +39,9 @@ class MailSet: self.ident += 1 return mail - + def find(self, draft_reply_for): + match = [mail for mail in self.mails.values() if mail.draft_reply_for ==draft_reply_for] + if len(match) == 0: + return None + else: + return match[0] diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py index 2abdb5a1..bae95dee 100644 --- a/py-fake-service/app/pixelated_user_agent.py +++ b/py-fake-service/app/pixelated_user_agent.py @@ -99,7 +99,11 @@ def contacts(): @app.route('/draft_reply_for/<int:mail_id>') def draft_reply_for(mail_id): - return respond_json(None) + mail = mail_service.draft_reply_for(mail_id) + if mail: + return respond_json(mail.__dict__) + else: + return respond_json(None) @app.route('/control/mailset/<mailset>/load', methods=['POST']) |