Fix assertions when we catch an error in the tests

Code that is within a `with Python.raises(...)` context manager but
comes after the line that raises the exception doesn't get evaluated.
We had some assertions that we never being tested because of this, so
this ensures that they will always get run and fixes them where
necessary.
This commit is contained in:
Katie Smith
2019-09-18 11:04:24 +01:00
parent f9f9092b5c
commit 09e8ac9644
8 changed files with 23 additions and 19 deletions
+2 -2
View File
@@ -139,7 +139,7 @@ def test_should_not_send_email_message_when_service_is_inactive_notifcation_is_i
with pytest.raises(NotificationTechnicalFailureException) as e:
send_to_providers.send_email_to_provider(sample_notification)
assert sample_notification.id in e.value
assert str(sample_notification.id) in str(e.value)
send_mock.assert_not_called()
assert Notification.query.get(sample_notification.id).status == 'technical-failure'
@@ -152,7 +152,7 @@ def test_should_not_send_sms_message_when_service_is_inactive_notifcation_is_in_
with pytest.raises(NotificationTechnicalFailureException) as e:
send_to_providers.send_sms_to_provider(sample_notification)
assert sample_notification.id in e.value
assert str(sample_notification.id) in str(e.value)
send_mock.assert_not_called()
assert Notification.query.get(sample_notification.id).status == 'technical-failure'