mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 08:44:23 -04:00
[WIp]
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import uuid
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
@@ -16,6 +15,7 @@ from app.utils import (
|
|||||||
get_letter_timings,
|
get_letter_timings,
|
||||||
get_cdn_domain
|
get_cdn_domain
|
||||||
)
|
)
|
||||||
|
from tests.conftest import fake_uuid
|
||||||
|
|
||||||
|
|
||||||
def _get_notifications_csv(
|
def _get_notifications_csv(
|
||||||
@@ -29,7 +29,8 @@ def _get_notifications_csv(
|
|||||||
status='Delivered',
|
status='Delivered',
|
||||||
created_at='Thursday 19 April at 12:00',
|
created_at='Thursday 19 April at 12:00',
|
||||||
rows=1,
|
rows=1,
|
||||||
with_links=False
|
with_links=False,
|
||||||
|
job_id=fake_uuid
|
||||||
):
|
):
|
||||||
links = {}
|
links = {}
|
||||||
if with_links:
|
if with_links:
|
||||||
@@ -60,7 +61,7 @@ def _get_notifications_csv(
|
|||||||
def _get_notifications_csv_mock(
|
def _get_notifications_csv_mock(
|
||||||
mocker,
|
mocker,
|
||||||
api_user_active,
|
api_user_active,
|
||||||
job_id=None
|
job_id=fake_uuid
|
||||||
):
|
):
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
'app.notification_api_client.get_notifications_for_service',
|
'app.notification_api_client.get_notifications_for_service',
|
||||||
@@ -124,13 +125,13 @@ def test_can_create_spreadsheet_from_dict_with_filename():
|
|||||||
|
|
||||||
|
|
||||||
def test_generate_notifications_csv_returns_correct_csv_file(_get_notifications_csv_mock):
|
def test_generate_notifications_csv_returns_correct_csv_file(_get_notifications_csv_mock):
|
||||||
csv_content = generate_notifications_csv(service_id='1234', job_id=uuid.uuid4())
|
csv_content = generate_notifications_csv(service_id='1234', job_id=fake_uuid)
|
||||||
csv_file = DictReader(StringIO('\n'.join(csv_content)))
|
csv_file = DictReader(StringIO('\n'.join(csv_content)))
|
||||||
assert csv_file.fieldnames == ['Row number', 'Recipient', 'Template', 'Type', 'Job', 'Status', 'Time']
|
assert csv_file.fieldnames == ['Row number', 'Recipient', 'Template', 'Type', 'Job', 'Status', 'Time']
|
||||||
|
|
||||||
|
|
||||||
def test_generate_notifications_csv_only_calls_once_if_no_next_link(_get_notifications_csv_mock):
|
def test_generate_notifications_csv_only_calls_once_if_no_next_link(_get_notifications_csv_mock):
|
||||||
list(generate_notifications_csv(service_id='1234', job_id=uuid.uuid4()))
|
list(generate_notifications_csv(service_id='1234', job_id=fake_uuid))
|
||||||
|
|
||||||
assert _get_notifications_csv_mock.call_count == 1
|
assert _get_notifications_csv_mock.call_count == 1
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ def test_generate_notifications_csv_calls_twice_if_next_link(mocker):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
csv_content = generate_notifications_csv(service_id=service_id, job_id=uuid.uuid4())
|
csv_content = generate_notifications_csv(service_id=service_id, job_id=fake_uuid)
|
||||||
csv = DictReader(StringIO('\n'.join(csv_content)))
|
csv = DictReader(StringIO('\n'.join(csv_content)))
|
||||||
|
|
||||||
assert len(list(csv)) == 10
|
assert len(list(csv)) == 10
|
||||||
|
|||||||
Reference in New Issue
Block a user