mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Sanitise uploaded letters and store in S3
This sanitises uploaded letters and stores the sanitised result in S3 with if it passes validation or the original PDF in S3 if validation fails. A metadata value of 'status' is set to either 'valid' or 'invalid'.
This commit is contained in:
@@ -4,7 +4,11 @@ from unittest.mock import Mock
|
||||
import pytest
|
||||
from notifications_utils.template import LetterPreviewTemplate
|
||||
|
||||
from app.template_previews import TemplatePreview, get_page_count_for_letter
|
||||
from app.template_previews import (
|
||||
TemplatePreview,
|
||||
get_page_count_for_letter,
|
||||
sanitise_letter,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('partial_call, expected_page_argument', [
|
||||
@@ -119,3 +123,15 @@ def test_from_example_template_makes_request(mocker):
|
||||
'filename': filename,
|
||||
'letter_contact_block': None}
|
||||
)
|
||||
|
||||
|
||||
def test_sanitise_letter_calls_template_preview_sanitise_endoint_with_file(mocker):
|
||||
request_mock = mocker.patch('app.template_previews.requests.post')
|
||||
|
||||
sanitise_letter('pdf_data')
|
||||
|
||||
request_mock.assert_called_once_with(
|
||||
'http://localhost:9999/precompiled/sanitise',
|
||||
headers={'Authorization': 'Token my-secret-key'},
|
||||
data='pdf_data'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user