mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-26 21:31:11 -05:00
Call mock rather than using fixture
Our get_notifications fixture tries to be too clever and work out which fields to return based on what arguments it’s called with. This is very indirect and makes the tests less specific. In other places we call the mocking code directly with arguments that make it more explicit what the mocked response should be. This commit does this for tests that we’d otherwise have to make changes to the fixture for, because postage can no longer be `None` for letter notifications.
This commit is contained in:
@@ -443,7 +443,8 @@ def notification_json(
|
||||
if status is None:
|
||||
status = 'delivered'
|
||||
links = {}
|
||||
postage = postage or 'second'
|
||||
if template_type == 'letter':
|
||||
postage = postage or 'second'
|
||||
|
||||
if with_links:
|
||||
links = {
|
||||
|
||||
@@ -349,13 +349,17 @@ def test_should_show_letter_job(
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00")
|
||||
def test_should_show_letter_job_with_banner_after_sending_before_1730(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_service_letter_template,
|
||||
mock_get_letter_job,
|
||||
mock_get_notifications,
|
||||
mock_get_service_data_retention,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
return_value=create_notifications(template_type='letter', postage='second')
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_job',
|
||||
@@ -373,13 +377,17 @@ def test_should_show_letter_job_with_banner_after_sending_before_1730(
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00")
|
||||
def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_service_letter_template,
|
||||
mock_get_letter_job_in_progress,
|
||||
mock_get_notifications,
|
||||
mock_get_service_data_retention,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
return_value=create_notifications(template_type='letter', postage='second')
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_job',
|
||||
@@ -396,13 +404,17 @@ def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows(
|
||||
|
||||
@freeze_time("2016-01-01 18:09:00")
|
||||
def test_should_show_letter_job_with_banner_after_sending_after_1730(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_service_letter_template,
|
||||
mock_get_letter_job,
|
||||
mock_get_notifications,
|
||||
mock_get_service_data_retention,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
return_value=create_notifications(template_type='letter', postage='second')
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_job',
|
||||
|
||||
Reference in New Issue
Block a user