Put the download csv link on the activity page.

Still needs some tests, probably some refactoring as well.
This commit is contained in:
Rebecca Law
2017-12-30 16:54:39 +00:00
parent 31b3147f1d
commit 259db9c271
5 changed files with 116 additions and 64 deletions

View File

@@ -1,3 +1,4 @@
import uuid
from pathlib import Path
from io import StringIO
from collections import OrderedDict
@@ -58,7 +59,8 @@ def _get_notifications_csv(
@pytest.fixture(scope='function')
def _get_notifications_csv_mock(
mocker,
api_user_active
api_user_active,
job_id=None
):
return mocker.patch(
'app.notification_api_client.get_notifications_for_service',
@@ -122,13 +124,13 @@ def test_can_create_spreadsheet_from_dict_with_filename():
def test_generate_notifications_csv_returns_correct_csv_file(_get_notifications_csv_mock):
csv_content = generate_notifications_csv(service_id='1234')
csv_content = generate_notifications_csv(service_id='1234', job_id=uuid.uuid4())
csv_file = DictReader(StringIO('\n'.join(csv_content)))
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):
list(generate_notifications_csv(service_id='1234'))
list(generate_notifications_csv(service_id='1234', job_id=uuid.uuid4()))
assert _get_notifications_csv_mock.call_count == 1
@@ -146,7 +148,7 @@ def test_generate_notifications_csv_calls_twice_if_next_link(mocker):
]
)
csv_content = generate_notifications_csv(service_id=service_id)
csv_content = generate_notifications_csv(service_id=service_id, job_id=uuid.uuid4())
csv = DictReader(StringIO('\n'.join(csv_content)))
assert len(list(csv)) == 10