mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 19:38:24 -04:00
update test_send_notification to account for new uuid mock
This commit is contained in:
@@ -228,7 +228,8 @@ post_letter_response = {
|
|||||||
"content": letter_content,
|
"content": letter_content,
|
||||||
"uri": {"type": "string", "format": "uri"},
|
"uri": {"type": "string", "format": "uri"},
|
||||||
"template": template,
|
"template": template,
|
||||||
"scheduled_for": {"type": ["string", "null"]}
|
# letters cannot be scheduled
|
||||||
|
"scheduled_for": {"type": "null"}
|
||||||
},
|
},
|
||||||
"required": ["id", "content", "uri", "template"]
|
"required": ["id", "content", "uri", "template"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,7 +276,6 @@ def test_create_job_returns_400_if_missing_data(notify_api, sample_template, moc
|
|||||||
assert resp_json['result'] == 'error'
|
assert resp_json['result'] == 'error'
|
||||||
assert 'Missing data for required field.' in resp_json['message']['original_file_name']
|
assert 'Missing data for required field.' in resp_json['message']['original_file_name']
|
||||||
assert 'Missing data for required field.' in resp_json['message']['notification_count']
|
assert 'Missing data for required field.' in resp_json['message']['notification_count']
|
||||||
assert 'Missing data for required field.' in resp_json['message']['id']
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_job_returns_404_if_template_does_not_exist(notify_api, sample_service, mocker):
|
def test_create_job_returns_404_if_template_does_not_exist(notify_api, sample_service, mocker):
|
||||||
|
|||||||
@@ -572,10 +572,9 @@ def test_should_not_send_sms_if_team_api_key_and_not_a_service_user(notify_api,
|
|||||||
] == json_resp['message']['to']
|
] == json_resp['message']['to']
|
||||||
|
|
||||||
|
|
||||||
def test_should_send_email_if_team_api_key_and_a_service_user(notify_api, sample_email_template, fake_uuid, mocker):
|
def test_should_send_email_if_team_api_key_and_a_service_user(client, sample_email_template, fake_uuid, mocker):
|
||||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
|
||||||
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'to': sample_email_template.service.created_by.email_address,
|
'to': sample_email_template.service.created_by.email_address,
|
||||||
@@ -603,11 +602,10 @@ def test_should_send_email_if_team_api_key_and_a_service_user(notify_api, sample
|
|||||||
@pytest.mark.parametrize('restricted', [True, False])
|
@pytest.mark.parametrize('restricted', [True, False])
|
||||||
@pytest.mark.parametrize('limit', [0, 1])
|
@pytest.mark.parametrize('limit', [0, 1])
|
||||||
def test_should_send_sms_to_anyone_with_test_key(
|
def test_should_send_sms_to_anyone_with_test_key(
|
||||||
notify_api, sample_template, mocker, restricted, limit, fake_uuid
|
client, sample_template, mocker, restricted, limit, fake_uuid
|
||||||
):
|
):
|
||||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
|
||||||
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'to': '07811111111',
|
'to': '07811111111',
|
||||||
@@ -638,11 +636,10 @@ def test_should_send_sms_to_anyone_with_test_key(
|
|||||||
@pytest.mark.parametrize('restricted', [True, False])
|
@pytest.mark.parametrize('restricted', [True, False])
|
||||||
@pytest.mark.parametrize('limit', [0, 1])
|
@pytest.mark.parametrize('limit', [0, 1])
|
||||||
def test_should_send_email_to_anyone_with_test_key(
|
def test_should_send_email_to_anyone_with_test_key(
|
||||||
notify_api, sample_email_template, mocker, restricted, limit, fake_uuid
|
client, sample_email_template, mocker, restricted, limit, fake_uuid
|
||||||
):
|
):
|
||||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
|
||||||
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'to': 'anyone123@example.com',
|
'to': 'anyone123@example.com',
|
||||||
@@ -671,10 +668,9 @@ def test_should_send_email_to_anyone_with_test_key(
|
|||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
|
||||||
|
|
||||||
def test_should_send_sms_if_team_api_key_and_a_service_user(notify_api, sample_template, fake_uuid, mocker):
|
def test_should_send_sms_if_team_api_key_and_a_service_user(client, sample_template, fake_uuid, mocker):
|
||||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
|
||||||
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'to': sample_template.service.created_by.mobile_number,
|
'to': sample_template.service.created_by.mobile_number,
|
||||||
@@ -710,7 +706,8 @@ def test_should_persist_notification(
|
|||||||
queue_name
|
queue_name
|
||||||
):
|
):
|
||||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_{}.apply_async'.format(template_type))
|
mocked = mocker.patch('app.celery.provider_tasks.deliver_{}.apply_async'.format(template_type))
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
template = sample_template if template_type == SMS_TYPE else sample_email_template
|
template = sample_template if template_type == SMS_TYPE else sample_email_template
|
||||||
to = sample_template.service.created_by.mobile_number if template_type == SMS_TYPE \
|
to = sample_template.service.created_by.mobile_number if template_type == SMS_TYPE \
|
||||||
else sample_email_template.service.created_by.email_address
|
else sample_email_template.service.created_by.email_address
|
||||||
@@ -757,7 +754,8 @@ def test_should_delete_notification_and_return_error_if_sqs_fails(
|
|||||||
'app.celery.provider_tasks.deliver_{}.apply_async'.format(template_type),
|
'app.celery.provider_tasks.deliver_{}.apply_async'.format(template_type),
|
||||||
side_effect=Exception("failed to talk to SQS")
|
side_effect=Exception("failed to talk to SQS")
|
||||||
)
|
)
|
||||||
mocker.patch('app.dao.notifications_dao.create_uuid', return_value=fake_uuid)
|
mocker.patch('app.notifications.process_notifications.uuid.uuid4', return_value=fake_uuid)
|
||||||
|
|
||||||
template = sample_template if template_type == SMS_TYPE else sample_email_template
|
template = sample_template if template_type == SMS_TYPE else sample_email_template
|
||||||
to = sample_template.service.created_by.mobile_number if template_type == SMS_TYPE \
|
to = sample_template.service.created_by.mobile_number if template_type == SMS_TYPE \
|
||||||
else sample_email_template.service.created_by.email_address
|
else sample_email_template.service.created_by.email_address
|
||||||
|
|||||||
Reference in New Issue
Block a user