mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04: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,
|
NotificationHistory,
|
||||||
Service,
|
Service,
|
||||||
StatsTemplateUsageByMonth,
|
StatsTemplateUsageByMonth,
|
||||||
Template,
|
|
||||||
JOB_STATUS_READY_TO_SEND,
|
JOB_STATUS_READY_TO_SEND,
|
||||||
JOB_STATUS_IN_PROGRESS,
|
JOB_STATUS_IN_PROGRESS,
|
||||||
JOB_STATUS_SENT_TO_DVLA,
|
JOB_STATUS_SENT_TO_DVLA,
|
||||||
@@ -81,14 +80,13 @@ def _create_slow_delivery_notification(provider='mmg'):
|
|||||||
service = create_service(
|
service = create_service(
|
||||||
service_id=current_app.config.get('FUNCTIONAL_TEST_PROVIDER_SERVICE_ID')
|
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(
|
||||||
template = create_custom_template(
|
service=service,
|
||||||
service=service,
|
user=service.users[0],
|
||||||
user=service.users[0],
|
template_config_name='FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID',
|
||||||
template_config_name='FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID',
|
template_type='sms'
|
||||||
template_type='sms'
|
)
|
||||||
)
|
|
||||||
|
|
||||||
create_notification(
|
create_notification(
|
||||||
template=template,
|
template=template,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from app import db
|
|||||||
from app.models import (
|
from app.models import (
|
||||||
Service,
|
Service,
|
||||||
Template,
|
Template,
|
||||||
|
TemplateHistory,
|
||||||
ApiKey,
|
ApiKey,
|
||||||
Job,
|
Job,
|
||||||
Notification,
|
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.invited_user_dao import save_invited_user
|
||||||
from app.dao.provider_rates_dao import create_provider_rates
|
from app.dao.provider_rates_dao import create_provider_rates
|
||||||
from app.clients.sms.firetext import FiretextClient
|
from app.clients.sms.firetext import FiretextClient
|
||||||
|
from app.history_meta import create_history
|
||||||
from tests import create_authorization_header
|
from tests import create_authorization_header
|
||||||
from tests.app.db import (
|
from tests.app.db import (
|
||||||
create_user,
|
create_user,
|
||||||
@@ -974,6 +976,7 @@ def create_custom_template(service, user, template_config_name, template_type, c
|
|||||||
}
|
}
|
||||||
template = Template(**data)
|
template = Template(**data)
|
||||||
db.session.add(template)
|
db.session.add(template)
|
||||||
|
db.session.add(create_history(template, TemplateHistory))
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return template
|
return template
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user