mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Add ServiceLetterContact data model and script
This commit is contained in:
@@ -26,7 +26,8 @@ from app.models import (
|
||||
INBOUND_SMS_TYPE,
|
||||
KEY_TYPE_NORMAL,
|
||||
ServiceInboundApi,
|
||||
ServiceEmailReplyTo
|
||||
ServiceEmailReplyTo,
|
||||
ServiceLetterContact
|
||||
)
|
||||
from app.dao.users_dao import save_model_user
|
||||
from app.dao.notifications_dao import dao_create_notification, dao_created_scheduled_notification
|
||||
@@ -347,3 +348,21 @@ def create_reply_to_email(
|
||||
db.session.commit()
|
||||
|
||||
return reply_to
|
||||
|
||||
|
||||
def create_letter_contact(
|
||||
service,
|
||||
contact_block,
|
||||
is_default=True
|
||||
):
|
||||
data = {
|
||||
'service': service,
|
||||
'contact_block': contact_block,
|
||||
'is_default': is_default,
|
||||
}
|
||||
letter_content = ServiceLetterContact(**data)
|
||||
|
||||
db.session.add(letter_content)
|
||||
db.session.commit()
|
||||
|
||||
return letter_content
|
||||
|
||||
@@ -21,7 +21,13 @@ from tests.app.conftest import (
|
||||
sample_template as create_sample_template,
|
||||
sample_notification_with_job as create_sample_notification_with_job
|
||||
)
|
||||
from tests.app.db import create_notification, create_service, create_inbound_number, create_reply_to_email
|
||||
from tests.app.db import (
|
||||
create_notification,
|
||||
create_service,
|
||||
create_inbound_number,
|
||||
create_reply_to_email,
|
||||
create_letter_contact
|
||||
)
|
||||
from tests.conftest import set_config
|
||||
|
||||
|
||||
@@ -262,3 +268,14 @@ def test_service_get_default_reply_to_email_address(sample_service):
|
||||
create_reply_to_email(service=sample_service, email_address="default@email.com")
|
||||
|
||||
assert sample_service.get_default_reply_to_email_address() == 'default@email.com'
|
||||
|
||||
|
||||
def test_service_get_default_contact_letter(sample_service):
|
||||
create_letter_contact(service=sample_service, contact_block='London,\nNW1A 1AA')
|
||||
|
||||
assert sample_service.get_default_letter_contact() == 'London,\nNW1A 1AA'
|
||||
|
||||
|
||||
# this test will need to be removed after letter_contact_block is dropped
|
||||
def test_service_get_default_letter_contact_block_from_service(sample_service):
|
||||
assert sample_service.get_default_letter_contact() == sample_service.letter_contact_block
|
||||
|
||||
Reference in New Issue
Block a user