summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-11-04 14:50:36 +0100
committerKali Kaneko (leap communications) <kali@leap.se>2016-11-04 14:50:55 +0100
commit68ecf00553bb870e6a2026e3672f0ac3268f274b (patch)
tree113bfe24df0b7c208de95cb28c9d5bed04aa7851 /tests
parent43065c466a7b7902ee9afbdbdb81a8e56b7fc54e (diff)
[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.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/mail/outgoing/test_service.py7
1 files changed, 5 insertions, 2 deletions
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 <http://www.gnu.org/licenses/>.
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)