diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2014-10-17 17:43:46 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-10-17 17:43:46 -0300 |
commit | 3aab6bd8c1ac45c2c5637bf86663f31cd4ea531c (patch) | |
tree | 60c7c09a53ac1c82b6ea23826af99ab00e5b24e1 /service/test | |
parent | 209729cbc97bf989cb9cb149c74d5cb2c1adc3b8 (diff) |
adds regression tests on #114 due to a bug found and fixes mail creation with predefined status that wasnt being set
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/integration/mark_as_read_unread_test.py | 32 | ||||
-rw-r--r-- | service/test/support/integration_helper.py | 2 |
2 files changed, 29 insertions, 5 deletions
diff --git a/service/test/integration/mark_as_read_unread_test.py b/service/test/integration/mark_as_read_unread_test.py index 3f83153d..3bf56dd5 100644 --- a/service/test/integration/mark_as_read_unread_test.py +++ b/service/test/integration/mark_as_read_unread_test.py @@ -16,6 +16,7 @@ import unittest from test.support.integration_helper import MailBuilder, SoledadTestBase +from pixelated.adapter.status import Status class MarkAsReadUnreadTest(unittest.TestCase, SoledadTestBase): @@ -39,7 +40,7 @@ class MarkAsReadUnreadTest(unittest.TestCase, SoledadTestBase): self.assertIn('read', mails[0].status) def test_mark_single_as_unread(self): - input_mail = MailBuilder().with_status('read').build_input_mail() + input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() self.add_mail_to_inbox(input_mail) @@ -49,8 +50,8 @@ class MarkAsReadUnreadTest(unittest.TestCase, SoledadTestBase): self.assertNotIn('read', mails[0].status) def test_mark_many_mails_as_unread(self): - input_mail = MailBuilder().with_status('read').build_input_mail() - input_mail2 = MailBuilder().with_status('read').build_input_mail() + input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() + input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() self.add_mail_to_inbox(input_mail) self.add_mail_to_inbox(input_mail2) @@ -74,7 +75,30 @@ class MarkAsReadUnreadTest(unittest.TestCase, SoledadTestBase): self.assertNotIn('read', mails[0].status) self.assertNotIn('read', mails[1].status) - self.mark_many_as_read([input_mail.ident, input_mail2.ident]) + response = self.mark_many_as_read([input_mail.ident, input_mail2.ident]) + self.assertEquals(200, response.status_code) + + mails = self.get_mails_by_tag('inbox') + + self.assertIn('read', mails[0].status) + self.assertIn('read', mails[1].status) + + def test_mark_mixed_status_as_read(self): + input_mail = MailBuilder().build_input_mail() + input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() + + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) + + mails = self.get_mails_by_tag('inbox') + + read_mails = filter(lambda x: 'read' in x.status, mails) + unread_mails = filter(lambda x: 'read' not in x.status, mails) + self.assertEquals(1, len(unread_mails)) + self.assertEquals(1, len(read_mails)) + + response = self.mark_many_as_read([input_mail.ident, input_mail2.ident]) + self.assertEquals(200, response.status_code) mails = self.get_mails_by_tag('inbox') diff --git a/service/test/support/integration_helper.py b/service/test/support/integration_helper.py index f6b4249e..3667001f 100644 --- a/service/test/support/integration_helper.py +++ b/service/test/support/integration_helper.py @@ -212,7 +212,7 @@ class SoledadTestBase: self.client.post('/mails/unread', data={'idents': json.dumps(idents)}) def mark_many_as_read(self, idents): - self.client.post('/mails/read', data={'idents': json.dumps(idents)}) + return self.client.post('/mails/read', data={'idents': json.dumps(idents)}) def add_mail_to_inbox(self, input_mail): mail = self.mailboxes.inbox().add(input_mail) |