mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Renamed the header of the CSV to 'to' from 'number' to allow for email jobs
- added new columns to Job and Notification to capture the start/end dates accurately
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from app.models import Notification
|
||||
|
||||
from datetime import datetime
|
||||
from app.dao.notifications_dao import (
|
||||
save_notification,
|
||||
dao_create_notification,
|
||||
dao_update_notification,
|
||||
get_notification,
|
||||
get_notification_for_job,
|
||||
get_notifications_for_job
|
||||
@@ -11,16 +12,16 @@ from app.dao.notifications_dao import (
|
||||
def test_save_notification(sample_template, sample_job):
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
to = '+44709123456'
|
||||
data = {
|
||||
'to': to,
|
||||
'to': '+44709123456',
|
||||
'job': sample_job,
|
||||
'service': sample_template.service,
|
||||
'template': sample_template
|
||||
'template': sample_template,
|
||||
'created_at': datetime.utcnow()
|
||||
}
|
||||
|
||||
notification = Notification(**data)
|
||||
save_notification(notification)
|
||||
dao_create_notification(notification)
|
||||
|
||||
assert Notification.query.count() == 1
|
||||
notification_from_db = Notification.query.all()[0]
|
||||
@@ -29,28 +30,30 @@ def test_save_notification(sample_template, sample_job):
|
||||
assert data['job'] == notification_from_db.job
|
||||
assert data['service'] == notification_from_db.service
|
||||
assert data['template'] == notification_from_db.template
|
||||
assert data['created_at'] == notification_from_db.created_at
|
||||
assert 'sent' == notification_from_db.status
|
||||
|
||||
|
||||
def test_get_notification(notify_db, notify_db_session, sample_notification):
|
||||
def test_get_notification(sample_notification):
|
||||
notifcation_from_db = get_notification(
|
||||
sample_notification.service.id,
|
||||
sample_notification.id)
|
||||
assert sample_notification == notifcation_from_db
|
||||
|
||||
|
||||
def test_save_notification_no_job_id(notify_db, notify_db_session, sample_template):
|
||||
def test_save_notification_no_job_id(sample_template):
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
to = '+44709123456'
|
||||
data = {
|
||||
'to': to,
|
||||
'service': sample_template.service,
|
||||
'template': sample_template
|
||||
'template': sample_template,
|
||||
'created_at': datetime.utcnow()
|
||||
}
|
||||
|
||||
notification = Notification(**data)
|
||||
save_notification(notification)
|
||||
dao_create_notification(notification)
|
||||
|
||||
assert Notification.query.count() == 1
|
||||
notification_from_db = Notification.query.all()[0]
|
||||
@@ -61,7 +64,7 @@ def test_save_notification_no_job_id(notify_db, notify_db_session, sample_templa
|
||||
assert 'sent' == notification_from_db.status
|
||||
|
||||
|
||||
def test_get_notification_for_job(notify_db, notify_db_session, sample_notification):
|
||||
def test_get_notification_for_job(sample_notification):
|
||||
notifcation_from_db = get_notification_for_job(
|
||||
sample_notification.service.id,
|
||||
sample_notification.job_id,
|
||||
@@ -83,17 +86,9 @@ def test_get_all_notifications_for_job(notify_db, notify_db_session, sample_job)
|
||||
assert len(notifcations_from_db) == 5
|
||||
|
||||
|
||||
def test_update_notification(notify_db, notify_db_session, sample_notification):
|
||||
def test_update_notification(sample_notification):
|
||||
assert sample_notification.status == 'sent'
|
||||
|
||||
update_dict = {
|
||||
'id': str(sample_notification.id),
|
||||
'service': str(sample_notification.service.id),
|
||||
'template': sample_notification.template.id,
|
||||
'job': str(sample_notification.job.id),
|
||||
'status': 'failed'
|
||||
}
|
||||
|
||||
save_notification(sample_notification, update_dict=update_dict)
|
||||
sample_notification.status = 'failed'
|
||||
dao_update_notification(sample_notification)
|
||||
notification_from_db = Notification.query.get(sample_notification.id)
|
||||
assert notification_from_db.status == 'failed'
|
||||
|
||||
Reference in New Issue
Block a user