rename letter get_folder_name args

`_now`? why would we ever use a different _now? instead say created_at,
because that's what it'll always be set to, even if we're replaying old
letters. We always set the folder name to when the letter was
created_at, or we might not know where to look to find it.

`dont_use_sending_date` doesn't really tell us what might happen if we
don't use it - the answer is we return an empty string. we ignore the
folder entirely. so lets call it that.

Also, remove use of freeze_gun in the tests, to prove that we don't use
the current time in any calculations. Also add an assert to a mock in
the get_pdf_for_templated_letter test, because we were mocking but not
asserting before, so the tests didn't fail when the function signature
changed.
This commit is contained in:
Leo Hemsted
2020-09-21 13:46:31 +01:00
parent 120b760cae
commit bb33927b3d
6 changed files with 33 additions and 23 deletions

View File

@@ -62,7 +62,10 @@ def test_get_pdf_for_templated_letter_happy_path(mocker, sample_letter_notificat
letter_branding = create_letter_branding(name=branding_name, filename=logo_filename)
sample_letter_notification.service.letter_branding = letter_branding
mock_celery = mocker.patch('app.celery.letters_pdf_tasks.notify_celery.send_task')
mocker.patch('app.celery.letters_pdf_tasks.get_letter_pdf_filename', return_value='LETTER.PDF')
mock_get_letter_pdf_filename = mocker.patch(
'app.celery.letters_pdf_tasks.get_letter_pdf_filename',
return_value='LETTER.PDF'
)
get_pdf_for_templated_letter(sample_letter_notification.id)
letter_data = {
@@ -87,6 +90,14 @@ def test_get_pdf_for_templated_letter_happy_path(mocker, sample_letter_notificat
queue=QueueNames.SANITISE_LETTERS
)
mock_get_letter_pdf_filename.assert_called_once_with(
reference=sample_letter_notification.reference,
crown=True,
sending_date=sample_letter_notification.created_at,
ignore_folder=False,
postage='second'
)
def test_get_pdf_for_templated_letter_non_existent_notification(notify_api, mocker, fake_uuid):
with pytest.raises(expected_exception=NoResultFound):