Skip to content

Commit

Permalink
Fix test that wasn't actually doing anything
Browse files Browse the repository at this point in the history
  • Loading branch information
vkurup committed Jul 24, 2015
1 parent b4f5a82 commit 76ecf62
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions rapidsms/router/blocking/tests/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import mock

from django.test import TestCase

from rapidsms.router.blocking import BlockingRouter
from rapidsms.backends.base import BackendBase
from rapidsms.tests.harness import RaisesBackend, CreateDataMixin
from rapidsms.tests.harness.backend import RaisesBackend
from rapidsms.tests.harness.base import CreateDataMixin
from rapidsms.errors import MessageSendingError


Expand Down Expand Up @@ -56,11 +60,12 @@ def test_backend_send_raises_error(self):
self.assertRaises(MessageSendingError, self.router.send_to_backend,
*args)

def test_send_captures_exception(self):
@mock.patch('rapidsms.router.blocking.router.logger')
def test_send_captures_exception(self, mock_logger):
"""BlockingRouter should catch exceptions during sending."""
backend = self.router.add_backend("backend", RaisesBackend)
msg = self.create_outgoing_message(backend=backend.model)
try:
self.router.send_outgoing(msg)
except Exception:
self.fail("send_outgoing should capture all excetpions.")
# shouldn't raise an error
self.router.send_outgoing(msg)
# but should log an exception
mock_logger.exception.assert_called_once_with('backend encountered an error while sending.')

0 comments on commit 76ecf62

Please sign in to comment.