mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Update create_custom_template test helper to create history object
`create_custom_template` is not using `dao_create_template` since it explicitly sets a template id. Notifications.template relationship now refers to a TemplateHistory objects, so we need to make sure that `create_custom_template` creates a matching TemplateHistory record when it creates a Template.
This commit is contained in:
@@ -48,7 +48,6 @@ from app.models import (
|
||||
NotificationHistory,
|
||||
Service,
|
||||
StatsTemplateUsageByMonth,
|
||||
Template,
|
||||
JOB_STATUS_READY_TO_SEND,
|
||||
JOB_STATUS_IN_PROGRESS,
|
||||
JOB_STATUS_SENT_TO_DVLA,
|
||||
@@ -81,14 +80,13 @@ def _create_slow_delivery_notification(provider='mmg'):
|
||||
service = create_service(
|
||||
service_id=current_app.config.get('FUNCTIONAL_TEST_PROVIDER_SERVICE_ID')
|
||||
)
|
||||
template = Template.query.get(current_app.config['FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID'])
|
||||
if not template:
|
||||
template = create_custom_template(
|
||||
service=service,
|
||||
user=service.users[0],
|
||||
template_config_name='FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID',
|
||||
template_type='sms'
|
||||
)
|
||||
|
||||
template = create_custom_template(
|
||||
service=service,
|
||||
user=service.users[0],
|
||||
template_config_name='FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID',
|
||||
template_type='sms'
|
||||
)
|
||||
|
||||
create_notification(
|
||||
template=template,
|
||||
|
||||
@@ -14,6 +14,7 @@ from app import db
|
||||
from app.models import (
|
||||
Service,
|
||||
Template,
|
||||
TemplateHistory,
|
||||
ApiKey,
|
||||
Job,
|
||||
Notification,
|
||||
@@ -38,6 +39,7 @@ from app.dao.notifications_dao import dao_create_notification
|
||||
from app.dao.invited_user_dao import save_invited_user
|
||||
from app.dao.provider_rates_dao import create_provider_rates
|
||||
from app.clients.sms.firetext import FiretextClient
|
||||
from app.history_meta import create_history
|
||||
from tests import create_authorization_header
|
||||
from tests.app.db import (
|
||||
create_user,
|
||||
@@ -974,6 +976,7 @@ def create_custom_template(service, user, template_config_name, template_type, c
|
||||
}
|
||||
template = Template(**data)
|
||||
db.session.add(template)
|
||||
db.session.add(create_history(template, TemplateHistory))
|
||||
db.session.commit()
|
||||
return template
|
||||
|
||||
|
||||
Reference in New Issue
Block a user