summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-11-23 10:26:20 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-11-23 10:26:20 +0100
commit3281c5eade3fadb32e199210ace922e3db8f6da6 (patch)
treea8cc1b988fb51b65e15024dd712ef1e9190db71f
parent25f3fb53f6e605c0885beda4ce73dafded50faef (diff)
Add test for mail deletion with invalid mail id
- Issue #511
-rw-r--r--service/test/unit/adapter/test_mail_service.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/service/test/unit/adapter/test_mail_service.py b/service/test/unit/adapter/test_mail_service.py
index d1a37d3d..d14a0eb0 100644
--- a/service/test/unit/adapter/test_mail_service.py
+++ b/service/test/unit/adapter/test_mail_service.py
@@ -20,7 +20,7 @@ from pixelated.adapter.model.status import Status
from pixelated.adapter.services.mail_service import MailService
from test.support.test_helper import mail_dict, leap_mail
-from mockito import mock, unstub, when, verify, verifyNoMoreInteractions, any as ANY
+from mockito import mock, unstub, when, verify, verifyNoMoreInteractions, any as ANY, never
from twisted.internet import defer
@@ -135,6 +135,17 @@ class TestMailService(unittest.TestCase):
verify(self.mail_store).move_mail_to_mailbox(1, 'TRASH')
@defer.inlineCallbacks
+ def test_delete_mail_does_not_fail_for_invalid_mail(self):
+ no_mail = None
+ mail_id = 1
+ when(self.mail_store).get_mail(mail_id, include_body=True).thenReturn(defer.succeed(no_mail))
+
+ yield self.mail_service.delete_mail(mail_id)
+
+ verify(self.mail_store, never).delete_mail(mail_id)
+ verify(self.mail_store, never).move_mail_to_mailbox(mail_id, ANY())
+
+ @defer.inlineCallbacks
def test_recover_mail(self):
mail_to_recover = LeapMail(1, 'TRASH')
when(self.mail_service).mail(1).thenReturn(mail_to_recover)