Refactor tests to use the create_notication in tests.app.db

This commit is contained in:
Rebecca Law
2017-05-25 11:41:07 +01:00
parent 9f6c037530
commit f555c7a73b
4 changed files with 103 additions and 105 deletions

View File

@@ -3,9 +3,9 @@ import uuid
from app.dao.jobs_dao import dao_create_job
from app.models import (Service, User, Template, Notification, EMAIL_TYPE, LETTER_TYPE,
SMS_TYPE, KEY_TYPE_NORMAL, Job, ServicePermission)
SMS_TYPE, KEY_TYPE_NORMAL, Job, ServicePermission, ScheduledNotification)
from app.dao.users_dao import save_model_user
from app.dao.notifications_dao import dao_create_notification
from app.dao.notifications_dao import dao_create_notification, dao_created_scheduled_notification
from app.dao.templates_dao import dao_create_template
from app.dao.services_dao import dao_create_service
from app.dao.service_permissions_dao import dao_add_service_permission
@@ -80,7 +80,8 @@ def create_notification(
client_reference=None,
rate_multiplier=None,
international=False,
phone_prefix=None
phone_prefix=None,
scheduled_for=None
):
if created_at is None:
created_at = datetime.utcnow()
@@ -118,6 +119,14 @@ def create_notification(
}
notification = Notification(**data)
dao_create_notification(notification)
if scheduled_for:
scheduled_notification = ScheduledNotification(id=uuid.uuid4(),
notification_id=notification.id,
scheduled_for=datetime.strptime(scheduled_for,
"%Y-%m-%d %H:%M"))
if status != 'created':
scheduled_notification.pending = False
dao_created_scheduled_notification(scheduled_notification)
return notification