mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Use personalisation to set client_reference for letters
which were sent through Notify interface only. This is done to avoid performance dip from additional operation for other notification types.
This commit is contained in:
@@ -1249,3 +1249,27 @@ def test_send_notification_should_send_international_letters(
|
||||
notification = Notification.query.get(notification_id['id'])
|
||||
assert notification.postage == expected_postage
|
||||
assert notification.international == expected_international
|
||||
|
||||
|
||||
@pytest.mark.parametrize('reference_paceholder,', [None, 'ref2'])
|
||||
def test_send_notification_should_set_client_reference_from_placeholder(
|
||||
sample_letter_template, mocker, reference_paceholder
|
||||
):
|
||||
deliver_mock = mocker.patch('app.celery.tasks.letters_pdf_tasks.get_pdf_for_templated_letter.apply_async')
|
||||
data = {
|
||||
'template_id': sample_letter_template.id,
|
||||
'personalisation': {
|
||||
'address_line_1': 'Jane',
|
||||
'address_line_2': 'Moss Lane',
|
||||
'address_line_3': 'SW1A 1AA',
|
||||
},
|
||||
'to': 'Jane',
|
||||
'created_by': sample_letter_template.service.created_by_id
|
||||
}
|
||||
if reference_paceholder:
|
||||
data['personalisation']['reference'] = reference_paceholder
|
||||
|
||||
notification_id = send_one_off_notification(sample_letter_template.service_id, data)
|
||||
assert deliver_mock.called
|
||||
notification = Notification.query.get(notification_id['id'])
|
||||
assert notification.client_reference == reference_paceholder
|
||||
|
||||
Reference in New Issue
Block a user