diff options
author | Neissi Torres Lima <neissi.lima@gmail.com> | 2014-10-26 21:14:53 -0200 |
---|---|---|
committer | Neissi Torres Lima <neissi.lima@gmail.com> | 2014-10-27 13:35:17 -0200 |
commit | e73adb674be3e24d73986fc087a7b98304891884 (patch) | |
tree | 1f3e76d89b0c8e5c4bb2bd10da12e1fc5795b8b2 | |
parent | 838c6c3564fa7b6fdbb09ffc35c044b0fd182c3c (diff) |
#112 - Created tests to delete permanentelly mails and move to trash
-rw-r--r-- | service/pixelated/controllers/mails_controller.py | 2 | ||||
-rw-r--r-- | service/test/unit/controllers/mails_controller_test.py | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py index 9e610d72..ebef4af1 100644 --- a/service/pixelated/controllers/mails_controller.py +++ b/service/pixelated/controllers/mails_controller.py @@ -80,7 +80,7 @@ class MailsController: def delete_mails(self): idents = json.loads(request.form['idents']) for ident in idents: - self._mail_service.delete_mail(ident) + self.delete_mail(ident) return respond_json(None) def send_mail(self, _request=request): diff --git a/service/test/unit/controllers/mails_controller_test.py b/service/test/unit/controllers/mails_controller_test.py index 8807cc72..af1e5c95 100644 --- a/service/test/unit/controllers/mails_controller_test.py +++ b/service/test/unit/controllers/mails_controller_test.py @@ -19,6 +19,7 @@ from mockito import * from pixelated.controllers.mails_controller import MailsController + class TestMailsController(unittest.TestCase): def setUp(self): @@ -87,11 +88,35 @@ class TestMailsController(unittest.TestCase): verify(self.mail_service).mark_as_unread(1) verify(self.search_engine).index_mail(mail) + def test_delete_permanently_when_mail_in_trash(self): + mail = mock() + mail.mailbox_name ='TRASH' + when(self.mail_service).mail(1).thenReturn(mail) + self.mails_controller.delete_mail(1) + + verify(self.mail_service).delete_permanent(1) + + def test_move_message_to_trash(self): + mail = mock() + mail.mailbox_name ='INBOX' + when(self.mail_service).mail(1).thenReturn(mail) + when(self.mails_controller).delete_mail(1).thenReturn(mail) + when(self.search_engine).index_mail(mail) + + verify(self.search_engine).index_mail(mail) + def _successfuly_send_mail(self, ident, mail): sent_mail = mock() + mail.mailbox_name ='TRASH' sent_mail.as_dict = lambda: self.input_mail.json return sent_mail def _send_that_throws_exception(self, ident, mail): raise Exception('email sending failed', 'more information of error', 123, 'there was a code before this') + + + + + + |