Tell template preview whether a letter can be sent internationally

If a service has permission to send international letters then the admin
app should tell template preview, so that template preview knows what
rules to apply when it’s validating the address of the letter.

We don’t need to wait for template preview to start looking at this
query string argument – it will just ignore it for now.
This commit is contained in:
Chris Hill-Scott
2020-04-30 12:11:37 +01:00
parent 0ef076f59e
commit 53724dacd1
4 changed files with 34 additions and 7 deletions

View File

@@ -164,13 +164,21 @@ def test_from_example_template_makes_request(mocker):
)
def test_sanitise_letter_calls_template_preview_sanitise_endoint_with_file(mocker):
@pytest.mark.parametrize('allow_international_letters, expected_url', (
(False, 'http://localhost:9999/precompiled/sanitise?allow_international_letters=false'),
(True, 'http://localhost:9999/precompiled/sanitise?allow_international_letters=true'),
))
def test_sanitise_letter_calls_template_preview_sanitise_endoint_with_file(
mocker,
allow_international_letters,
expected_url,
):
request_mock = mocker.patch('app.template_previews.requests.post')
sanitise_letter('pdf_data')
sanitise_letter('pdf_data', allow_international_letters=allow_international_letters)
request_mock.assert_called_once_with(
'http://localhost:9999/precompiled/sanitise',
expected_url,
headers={'Authorization': 'Token my-secret-key'},
data='pdf_data'
)