Improvements to the tests.

Update AuthError with a to_dict_v2 method.
This commit is contained in:
Rebecca Law
2016-11-01 10:33:34 +00:00
parent a358f3cb3a
commit 482d10545b
8 changed files with 58 additions and 46 deletions

View File

@@ -97,17 +97,15 @@ def test_service_can_send_to_recipient_passes_for_live_service_non_team_member(k
live_service) is None
@pytest.mark.parametrize('key_type',
['team'])
def test_service_can_send_to_recipient_passes_for_whitelisted_recipient_passes(key_type, notify_db, notify_db_session,
def test_service_can_send_to_recipient_passes_for_whitelisted_recipient_passes(notify_db, notify_db_session,
sample_service):
sample_service_whitelist(notify_db, notify_db_session, email_address="some_other_email@test.com")
assert service_can_send_to_recipient("some_other_email@test.com",
key_type,
'team',
sample_service) is None
sample_service_whitelist(notify_db, notify_db_session, mobile_number='07513332413')
assert service_can_send_to_recipient('07513332413',
key_type,
'team',
sample_service) is None
@@ -120,9 +118,9 @@ def test_service_can_send_to_recipient_fails_when_recipient_is_not_on_team(recip
notify_db, notify_db_session):
trial_mode_service = create_service(notify_db, notify_db_session, service_name='trial mode', restricted=True)
with pytest.raises(BadRequestError) as exec_info:
assert service_can_send_to_recipient(recipient,
key_type,
trial_mode_service) is None
service_can_send_to_recipient(recipient,
key_type,
trial_mode_service)
assert exec_info.value.status_code == 400
assert exec_info.value.code == 10400
assert exec_info.value.message == error_message
@@ -133,9 +131,9 @@ def test_service_can_send_to_recipient_fails_when_recipient_is_not_on_team(recip
def test_service_can_send_to_recipient_fails_when_mobile_number_is_not_on_team(notify_db, notify_db_session):
live_service = create_service(notify_db, notify_db_session, service_name='live mode', restricted=False)
with pytest.raises(BadRequestError) as e:
assert service_can_send_to_recipient("0758964221",
'team',
live_service) is None
service_can_send_to_recipient("0758964221",
'team',
live_service)
assert e.value.status_code == 400
assert e.value.code == 10400
assert e.value.message == 'Cant send to this recipient using a team-only API key'