From e73adb674be3e24d73986fc087a7b98304891884 Mon Sep 17 00:00:00 2001 From: Neissi Torres Lima Date: Sun, 26 Oct 2014 21:14:53 -0200 Subject: #112 - Created tests to delete permanentelly mails and move to trash --- service/pixelated/controllers/mails_controller.py | 2 +- .../test/unit/controllers/mails_controller_test.py | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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') + + + + + + -- cgit v1.2.3