Use sample_broadcast_service fixture

Now that every service has a row in the service_broadcast_settings
table, we want all our tests to use the `sample_broadcast_service`
fixture as this ensures it has a row in that table and is correctly
representitive of what a real broadcast service looks like.
This commit is contained in:
David McDonald
2021-02-19 11:33:05 +00:00
parent ce2f550387
commit 9b21e6b04f
3 changed files with 45 additions and 60 deletions

View File

@@ -282,23 +282,22 @@ def test_get_service_by_id(admin_request, sample_service):
}
def test_get_service_by_id_returns_allowed_broadcast_provider(notify_db, admin_request, sample_service):
settings = ServiceBroadcastSettings(service=sample_service, channel="severe", provider="ee")
notify_db.session.add(settings)
json_resp = admin_request.get('service.get_service_by_id', service_id=sample_service.id)
assert json_resp['data']['id'] == str(sample_service.id)
assert json_resp['data']['allowed_broadcast_provider'] == 'ee'
def test_get_service_by_id_for_broadcast_service_takes_channel_from_service_broadcast_settings(
admin_request, sample_broadcast_service
@pytest.mark.parametrize('broadcast_channel,allowed_broadcast_provider', (
('test', None),
('severe', None),
('test', 'ee'),
('severe', 'three'),
))
def test_get_service_by_id_for_broadcast_service_returns_broadcast_keys(
notify_db, admin_request, sample_broadcast_service, broadcast_channel, allowed_broadcast_provider
):
assert sample_broadcast_service.broadcast_channel == 'severe'
sample_broadcast_service.broadcast_channel = broadcast_channel
sample_broadcast_service.allowed_broadcast_provider = allowed_broadcast_provider
json_resp = admin_request.get('service.get_service_by_id', service_id=sample_broadcast_service.id)
assert json_resp['data']['id'] == str(sample_broadcast_service.id)
assert json_resp['data']['broadcast_channel'] == 'severe'
assert json_resp['data']['allowed_broadcast_provider'] == allowed_broadcast_provider
assert json_resp['data']['broadcast_channel'] == broadcast_channel
def test_get_service_by_id_for_service_with_broadcast_permission_sets_channel_as_test_if_no_service_broadcast_settings(