summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-19 10:23:07 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-19 10:23:07 -0300
commit90aff82d713e4c288612ad8c339e7613be706781 (patch)
treefd8b64238edc5c09113f31d1b05ba7df0040506c /service
parente3871a45b584e8dcb633ba314e1ab1b8593c636b (diff)
Update draft route
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/mail_service.py3
-rw-r--r--service/pixelated/user_agent.py4
-rw-r--r--service/test/user_agent_test.py12
3 files changed, 15 insertions, 4 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py
index 6906c431..60f985da 100644
--- a/service/pixelated/adapter/mail_service.py
+++ b/service/pixelated/adapter/mail_service.py
@@ -48,6 +48,9 @@ class MailService:
def create_draft(self, mail):
return self.mailboxes.add_draft(mail)
+ def update_draft(self, mail):
+ return self.mailboxes.update_draft(mail)
+
def send_draft(self, mail):
pass
diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py
index c386c6e6..7adff10b 100644
--- a/service/pixelated/user_agent.py
+++ b/service/pixelated/user_agent.py
@@ -71,8 +71,8 @@ def send_mail():
@app.route('/mails', methods=['PUT'])
def update_draft():
- raw_mail = json.parse(request.json)
- ident = mail_service.update_mail(raw_mail)
+ _mail = PixelatedMail.from_dict(request.json)
+ ident = mail_service.update_draft(_mail)
return respond_json({'ident': ident})
diff --git a/service/test/user_agent_test.py b/service/test/user_agent_test.py
index 8661a59a..32557f39 100644
--- a/service/test/user_agent_test.py
+++ b/service/test/user_agent_test.py
@@ -32,7 +32,7 @@ class UserAgentTest(unittest.TestCase):
def test_create_or_send_draft_should_create_draft_if_mail_has_no_ident(self):
mail = self.mail_without_ident()
- pixelated.adapter.pixelated_mail.from_dict = lambda self: mail # has no ident
+ pixelated.adapter.pixelated_mail.from_dict = lambda x: mail # has no ident
self.app.post('/mails', data='{}', content_type="application/json")
@@ -40,12 +40,20 @@ class UserAgentTest(unittest.TestCase):
def test_create_or_send_draft_should_send_draft_if_mail_has_ident(self):
mail = self.mail_with_ident()
- pixelated.adapter.pixelated_mail.from_dict = lambda self: mail # does have ident
+ pixelated.adapter.pixelated_mail.from_dict = lambda x: mail # does have ident
self.app.post('/mails', data='{}', content_type="application/json")
verify(self.mail_service).send_draft(mail)
+ def test_update_draft(self):
+ mail = PixelatedMail()
+ pixelated.adapter.pixelated_mail.from_dict = lambda x: mail
+
+ self.app.put('/mails', data='{}', content_type="application/json")
+
+ verify(self.mail_service).update_draft(mail)
+
def mail_without_ident(self):
mail = PixelatedMail()
mail.ident = ''