mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Refactor tests to use the create_notication in tests.app.db
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user