mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-07 01:28:26 -04:00
Check the service is active before sending the notification to the provider.
This commit is contained in:
@@ -117,6 +117,19 @@ def test_should_send_personalised_template_to_correct_email_provider_and_persist
|
||||
assert notification.personalisation == {"name": "Jo"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("client_send",
|
||||
["app.aws_ses_client.send_email",
|
||||
"app.mmg_client.send_sms",
|
||||
"app.firetext_client.send_sms"])
|
||||
def test_should_not_send_message_when_service_is_inactive(sample_service, sample_notification, mocker,
|
||||
client_send):
|
||||
sample_service.active = False
|
||||
send_to_providers.send_email_to_provider(sample_notification)
|
||||
send_mock = mocker.patch(client_send, return_value='reference')
|
||||
|
||||
send_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_send_sms_should_use_template_version_from_notification_not_latest(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
|
||||
@@ -170,7 +170,7 @@ def test_create_scheduled_job(notify_api, sample_template, mocker, fake_uuid):
|
||||
assert resp_json['data']['original_file_name'] == 'thisisatest.csv'
|
||||
|
||||
|
||||
def test_create_job_returns_400_if_service_is_not_active(client, fake_uuid, sample_service, mocker):
|
||||
def test_create_job_returns_403_if_service_is_not_active(client, fake_uuid, sample_service, mocker):
|
||||
sample_service.active = False
|
||||
mock_job_dao = mocker.patch("app.dao.jobs_dao.dao_create_job")
|
||||
auth_header = create_authorization_header()
|
||||
@@ -178,7 +178,10 @@ def test_create_job_returns_400_if_service_is_not_active(client, fake_uuid, samp
|
||||
data="",
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
|
||||
assert response.status_code == 400
|
||||
assert response.status_code == 403
|
||||
resp_json = json.loads(response.get_data(as_text=True))
|
||||
assert resp_json['result'] == 'error'
|
||||
assert resp_json['message'] == "Create job is not allowed: service is inactive "
|
||||
mock_job_dao.assert_not_called()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user