From 68ecf00553bb870e6a2026e3672f0ac3268f274b Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Fri, 4 Nov 2016 14:50:36 +0100 Subject: [tests] do not mock failures in the variant that was merged, we call a failure method to get the exception, so it's better to test a real failure initialized with an exception. besides, I'm starting to hate mocks. --- tests/unit/mail/outgoing/test_service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/unit/mail') diff --git a/tests/unit/mail/outgoing/test_service.py b/tests/unit/mail/outgoing/test_service.py index 30518ccf..9200397b 100644 --- a/tests/unit/mail/outgoing/test_service.py +++ b/tests/unit/mail/outgoing/test_service.py @@ -16,7 +16,10 @@ # along with this program. If not, see . import unittest + from mock import MagicMock +from twisted.python.failure import Failure + from leap.bitmask.mail.outgoing.service import OutgoingMail @@ -36,7 +39,7 @@ class TestService(unittest.TestCase): self.cert, self.key, self.host, self.port, bouncer) - failure = MagicMock() + failure = Failure(exc_value=Exception()) origmsg = 'message' outgoing_mail.sendError(failure, origmsg) @@ -48,7 +51,7 @@ class TestService(unittest.TestCase): self.cert, self.key, self.host, self.port, bouncer) - failure = MagicMock(value=Exception('smtp error')) + failure = Failure(exc_value=Exception('smtp error')) origmsg = 'message' with self.assertRaises(Exception): outgoing_mail.sendError(failure, origmsg) -- cgit v1.2.3