mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Use new default letter contact in the DVLA celery task
This commit is contained in:
@@ -370,7 +370,7 @@ def create_dvla_file_contents_for_notifications(notifications):
|
|||||||
notification.template.__dict__,
|
notification.template.__dict__,
|
||||||
notification.personalisation,
|
notification.personalisation,
|
||||||
notification_reference=notification.reference,
|
notification_reference=notification.reference,
|
||||||
contact_block=notification.service.letter_contact_block,
|
contact_block=notification.service.get_default_letter_contact(),
|
||||||
org_id=notification.service.dvla_organisation.id,
|
org_id=notification.service.dvla_organisation.id,
|
||||||
))
|
))
|
||||||
for notification in notifications
|
for notification in notifications
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
@@ -29,14 +28,17 @@ from app.celery.tasks import (
|
|||||||
from app.config import QueueNames
|
from app.config import QueueNames
|
||||||
from app.dao import jobs_dao, services_dao
|
from app.dao import jobs_dao, services_dao
|
||||||
from app.models import (
|
from app.models import (
|
||||||
Notification,
|
EMAIL_TYPE,
|
||||||
|
JOB_STATUS_ERROR,
|
||||||
|
KEY_TYPE_NORMAL,
|
||||||
KEY_TYPE_TEAM,
|
KEY_TYPE_TEAM,
|
||||||
KEY_TYPE_TEST,
|
KEY_TYPE_TEST,
|
||||||
KEY_TYPE_NORMAL,
|
|
||||||
SMS_TYPE,
|
|
||||||
EMAIL_TYPE,
|
|
||||||
LETTER_TYPE,
|
LETTER_TYPE,
|
||||||
Job)
|
SERVICE_PERMISSION_TYPES,
|
||||||
|
SMS_TYPE,
|
||||||
|
Job,
|
||||||
|
Notification
|
||||||
|
)
|
||||||
|
|
||||||
from tests.app import load_example_csv
|
from tests.app import load_example_csv
|
||||||
from tests.app.conftest import (
|
from tests.app.conftest import (
|
||||||
@@ -46,7 +48,16 @@ from tests.app.conftest import (
|
|||||||
sample_email_template as create_sample_email_template,
|
sample_email_template as create_sample_email_template,
|
||||||
sample_notification as create_sample_notification
|
sample_notification as create_sample_notification
|
||||||
)
|
)
|
||||||
from tests.app.db import create_user, create_notification, create_job, create_service_inbound_api, create_inbound_sms
|
from tests.app.db import (
|
||||||
|
create_inbound_sms,
|
||||||
|
create_job,
|
||||||
|
create_letter_contact,
|
||||||
|
create_notification,
|
||||||
|
create_service_inbound_api,
|
||||||
|
create_service,
|
||||||
|
create_template,
|
||||||
|
create_user
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AnyStringWith(str):
|
class AnyStringWith(str):
|
||||||
@@ -1076,8 +1087,11 @@ def test_build_dvla_file_retries_if_all_notifications_are_not_created(sample_let
|
|||||||
mocked_send_task.assert_not_called()
|
mocked_send_task.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
def test_create_dvla_file_contents_for_job(sample_letter_template, mocker):
|
def test_create_dvla_file_contents(notify_db_session, mocker):
|
||||||
job = create_job(template=sample_letter_template, notification_count=2)
|
service = create_service(service_permissions=SERVICE_PERMISSION_TYPES)
|
||||||
|
create_letter_contact(service=service, contact_block='London,\nNW1A 1AA')
|
||||||
|
letter_template = create_template(service=service, template_type=LETTER_TYPE)
|
||||||
|
job = create_job(template=letter_template, notification_count=2)
|
||||||
create_notification(template=job.template, job=job, reference=1)
|
create_notification(template=job.template, job=job, reference=1)
|
||||||
create_notification(template=job.template, job=job, reference=2)
|
create_notification(template=job.template, job=job, reference=2)
|
||||||
mocked_letter_template = mocker.patch("app.celery.tasks.LetterDVLATemplate")
|
mocked_letter_template = mocker.patch("app.celery.tasks.LetterDVLATemplate")
|
||||||
@@ -1093,9 +1107,8 @@ def test_create_dvla_file_contents_for_job(sample_letter_template, mocker):
|
|||||||
# Personalisation
|
# Personalisation
|
||||||
assert not calls[0][0][1]
|
assert not calls[0][0][1]
|
||||||
assert not calls[1][0][1]
|
assert not calls[1][0][1]
|
||||||
|
|
||||||
# Named arguments
|
# Named arguments
|
||||||
assert calls[1][1]['contact_block'] == 'London,\nSW1A 1AA'
|
assert calls[1][1]['contact_block'] == 'London,\nNW1A 1AA'
|
||||||
assert calls[0][1]['notification_reference'] == '1'
|
assert calls[0][1]['notification_reference'] == '1'
|
||||||
assert calls[1][1]['notification_reference'] == '2'
|
assert calls[1][1]['notification_reference'] == '2'
|
||||||
assert calls[1][1]['org_id'] == '001'
|
assert calls[1][1]['org_id'] == '001'
|
||||||
|
|||||||
Reference in New Issue
Block a user