Check for suspension before sending a broadcast

This mirrors the check we do for jobs, which are also a high-impact
task [1]. While this shouldn't be possible, just like other checks
we're adding it here to be doubly certain.

[1]: 3d71815956/app/celery/tasks.py (L74)
This commit is contained in:
Ben Thorner
2021-04-19 15:27:20 +01:00
parent b2398fcaf4
commit 0070473f31
2 changed files with 19 additions and 0 deletions

View File

@@ -735,6 +735,19 @@ def test_check_provider_message_should_send_raises_if_current_event_already_has_
check_provider_message_should_send(current_event, 'ee')
def test_check_provider_message_should_send_raises_if_service_is_suspended(
sample_broadcast_service,
):
sample_broadcast_service.active = False
broadcast_message = create_broadcast_message(service=sample_broadcast_service, content='test')
current_event = create_broadcast_event(broadcast_message, message_type='alert')
with pytest.raises(BroadcastIntegrityError) as exc:
check_provider_message_should_send(current_event, 'ee')
assert 'service is suspended' in str(exc.value)
def test_send_broadcast_provider_message_does_nothing_if_cbc_proxy_disabled(mocker, notify_api, sample_template):
mock_proxy_client_getter = mocker.patch(
'app.celery.broadcast_message_tasks.cbc_proxy_client',