mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 16:31:15 -05:00
Endpoint to allow SES updates to occur
- update notification with delivery state
This commit is contained in:
@@ -16,12 +16,36 @@ from app.dao.notifications_dao import (
|
||||
dao_get_notification_statistics_for_service,
|
||||
delete_successful_notifications_created_more_than_a_day_ago,
|
||||
delete_failed_notifications_created_more_than_a_week_ago,
|
||||
dao_get_notification_statistics_for_service_and_day
|
||||
dao_get_notification_statistics_for_service_and_day,
|
||||
update_notification_status_by_id,
|
||||
update_notification_status_by_to
|
||||
)
|
||||
from tests.app.conftest import sample_job
|
||||
from tests.app.conftest import sample_notification
|
||||
|
||||
|
||||
def test_should_by_able_to_update_status_by_id(sample_notification):
|
||||
assert Notification.query.get(sample_notification.id).status == 'sent'
|
||||
count = update_notification_status_by_id(sample_notification.id, 'delivered')
|
||||
assert count == 1
|
||||
assert Notification.query.get(sample_notification.id).status == 'delivered'
|
||||
|
||||
|
||||
def test_should_return_zero_count_if_no_notification_with_id():
|
||||
assert update_notification_status_by_id(str(uuid.uuid4()), 'delivered') == 0
|
||||
|
||||
|
||||
def test_should_return_zero_count_if_no_notification_with_to():
|
||||
assert update_notification_status_by_to('something', 'delivered') == 0
|
||||
|
||||
|
||||
def test_should_by_able_to_update_status_by_to(sample_notification):
|
||||
assert Notification.query.get(sample_notification.id).status == 'sent'
|
||||
count = update_notification_status_by_to(sample_notification.to, 'delivered')
|
||||
assert count == 1
|
||||
assert Notification.query.get(sample_notification.id).status == 'delivered'
|
||||
|
||||
|
||||
def test_should_be_able_to_get_statistics_for_a_service(sample_template):
|
||||
data = {
|
||||
'to': '+44709123456',
|
||||
@@ -568,7 +592,7 @@ def test_should_not_delete_sent_notifications_before_one_day(notify_db, notify_d
|
||||
|
||||
def test_should_not_delete_failed_notifications_before_seven_days(notify_db, notify_db_session):
|
||||
expired = datetime.utcnow() - timedelta(hours=24 * 7)
|
||||
valid = datetime.utcnow() - timedelta(hours=(24 * 6) + 23, minutes=59, seconds=59)
|
||||
valid = datetime.utcnow() - timedelta(hours=(24 * 6) + 23, minutes=59, seconds=59)
|
||||
sample_notification(notify_db, notify_db_session, created_at=expired, status="failed", to_field="expired")
|
||||
sample_notification(notify_db, notify_db_session, created_at=valid, status="failed", to_field="valid")
|
||||
assert len(Notification.query.all()) == 2
|
||||
|
||||
Reference in New Issue
Block a user