diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-12-23 16:40:08 -0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-12-23 16:40:08 -0200 |
commit | d6fcbb1fbe3d791ed5da6935b9cc6190b56f01cb (patch) | |
tree | aeadd1cc50000a1dcab7434e0024bf652c3747a0 /service/test/integration | |
parent | 667c75e1af204dec1ab6b64c575ff17ffa2458aa (diff) |
#216 when trying to save a draft too fast (before the previous version is saved) simply ignore the attempt
Diffstat (limited to 'service/test/integration')
-rw-r--r-- | service/test/integration/drafts_test.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/service/test/integration/drafts_test.py b/service/test/integration/drafts_test.py index 2ba14dfd..d4fde099 100644 --- a/service/test/integration/drafts_test.py +++ b/service/test/integration/drafts_test.py @@ -28,7 +28,7 @@ class DraftsTest(SoledadTestBase): def test_post_sends_mail_and_deletes_previous_draft_if_it_exists(self): # creates one draft first_draft = MailBuilder().with_subject('First draft').build_json() - first_draft_ident = self.put_mail(first_draft) + first_draft_ident = self.put_mail(first_draft)[0]['ident'] # sends an updated version of the draft second_draft = MailBuilder().with_subject('Second draft').with_ident(first_draft_ident).build_json() @@ -64,7 +64,7 @@ class DraftsTest(SoledadTestBase): def test_put_updates_draft_if_it_already_exists(self): draft = MailBuilder().with_subject('First draft').build_json() - draft_ident = self.put_mail(draft) + draft_ident = self.put_mail(draft)[0]['ident'] updated_draft = MailBuilder().with_subject('First draft edited').with_ident(draft_ident).build_json() self.put_mail(updated_draft) @@ -73,3 +73,12 @@ class DraftsTest(SoledadTestBase): self.assertEquals(1, len(drafts)) self.assertEquals('First draft edited', drafts[0].subject) + + def test_respond_unprocessable_entity_if_draft_to_remove_doesnt_exist(self): + draft = MailBuilder().with_subject('First draft').build_json() + self.put_mail(draft) + + updated_draft = MailBuilder().with_subject('First draft edited').with_ident('NOTFOUND').build_json() + _, request = self.put_mail(updated_draft) + + self.assertEquals(422, request.code) |