mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Merge branch 'master' into seperate-queues-for-sending-and-for-db
This commit is contained in:
@@ -162,10 +162,6 @@ def test_firetext_callback_should_update_notification_status(notify_api, sample_
|
||||
updated = get_notification_by_id(sample_notification.id)
|
||||
assert updated.status == 'delivered'
|
||||
assert get_notification_by_id(sample_notification.id).status == 'delivered'
|
||||
stats = get_notification_stats(sample_notification.service_id)
|
||||
assert stats.sms_delivered == 1
|
||||
assert stats.sms_requested == 1
|
||||
assert stats.sms_failed == 0
|
||||
|
||||
|
||||
def test_firetext_callback_should_update_notification_status_failed(notify_api, sample_notification, mocker):
|
||||
@@ -189,10 +185,6 @@ def test_firetext_callback_should_update_notification_status_failed(notify_api,
|
||||
sample_notification.id
|
||||
)
|
||||
assert get_notification_by_id(sample_notification.id).status == 'permanent-failure'
|
||||
stats = get_notification_stats(sample_notification.service_id)
|
||||
assert stats.sms_delivered == 0
|
||||
assert stats.sms_requested == 1
|
||||
assert stats.sms_failed == 1
|
||||
|
||||
|
||||
def test_firetext_callback_should_update_notification_status_pending(notify_api, notify_db, notify_db_session, mocker):
|
||||
@@ -217,10 +209,6 @@ def test_firetext_callback_should_update_notification_status_pending(notify_api,
|
||||
notification.id
|
||||
)
|
||||
assert get_notification_by_id(notification.id).status == 'pending'
|
||||
stats = get_notification_stats(notification.service_id)
|
||||
assert stats.sms_delivered == 0
|
||||
assert stats.sms_requested == 1
|
||||
assert stats.sms_failed == 0
|
||||
|
||||
|
||||
def test_firetext_callback_should_update_multiple_notification_status_sent(
|
||||
@@ -257,11 +245,6 @@ def test_firetext_callback_should_update_multiple_notification_status_sent(
|
||||
),
|
||||
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
|
||||
|
||||
stats = get_notification_stats(notification1.service_id)
|
||||
assert stats.sms_delivered == 3
|
||||
assert stats.sms_requested == 3
|
||||
assert stats.sms_failed == 0
|
||||
|
||||
|
||||
def test_process_mmg_response_return_200_when_cid_is_send_sms_code(notify_api):
|
||||
with notify_api.test_request_context():
|
||||
@@ -481,10 +464,6 @@ def test_ses_callback_should_update_notification_status(
|
||||
assert json_resp['result'] == 'success'
|
||||
assert json_resp['message'] == 'SES callback succeeded'
|
||||
assert get_notification_by_id(notification.id).status == 'delivered'
|
||||
stats = get_notification_stats(notification.service_id)
|
||||
assert stats.emails_delivered == 1
|
||||
assert stats.emails_requested == 1
|
||||
assert stats.emails_failed == 0
|
||||
|
||||
|
||||
def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
@@ -536,11 +515,6 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
assert resp2.status_code == 200
|
||||
assert resp3.status_code == 200
|
||||
|
||||
stats = get_notification_stats(notification1.service_id)
|
||||
assert stats.emails_delivered == 3
|
||||
assert stats.emails_requested == 3
|
||||
assert stats.emails_failed == 0
|
||||
|
||||
|
||||
def test_ses_callback_should_set_status_to_temporary_failure(notify_api,
|
||||
notify_db,
|
||||
@@ -568,10 +542,6 @@ def test_ses_callback_should_set_status_to_temporary_failure(notify_api,
|
||||
assert json_resp['result'] == 'success'
|
||||
assert json_resp['message'] == 'SES callback succeeded'
|
||||
assert get_notification_by_id(notification.id).status == 'temporary-failure'
|
||||
stats = get_notification_stats(notification.service_id)
|
||||
assert stats.emails_delivered == 0
|
||||
assert stats.emails_requested == 1
|
||||
assert stats.emails_failed == 1
|
||||
|
||||
|
||||
def test_ses_callback_should_not_set_status_once_status_is_delivered(notify_api,
|
||||
@@ -628,10 +598,6 @@ def test_ses_callback_should_set_status_to_permanent_failure(notify_api,
|
||||
assert json_resp['result'] == 'success'
|
||||
assert json_resp['message'] == 'SES callback succeeded'
|
||||
assert get_notification_by_id(notification.id).status == 'permanent-failure'
|
||||
stats = get_notification_stats(notification.service_id)
|
||||
assert stats.emails_delivered == 0
|
||||
assert stats.emails_requested == 1
|
||||
assert stats.emails_failed == 1
|
||||
|
||||
|
||||
def test_should_handle_invite_email_callbacks(notify_api, notify_db, notify_db_session):
|
||||
|
||||
@@ -2,6 +2,7 @@ from datetime import date, timedelta
|
||||
|
||||
from flask import json
|
||||
from freezegun import freeze_time
|
||||
from datetime import datetime
|
||||
|
||||
from tests import create_authorization_header
|
||||
from tests.app.conftest import (
|
||||
@@ -196,7 +197,6 @@ def test_get_notification_statistics_returns_both_existing_stats_and_generated_z
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@freeze_time('1955-11-05T12:00:00')
|
||||
def test_get_notification_statistics_returns_zeros_when_only_stats_for_different_date(
|
||||
notify_api,
|
||||
sample_notification_statistics
|
||||
@@ -208,7 +208,7 @@ def test_get_notification_statistics_returns_zeros_when_only_stats_for_different
|
||||
service_id=sample_notification_statistics.service_id
|
||||
)
|
||||
response = client.get(
|
||||
'/notifications/statistics?day={}'.format(date.today().isoformat()),
|
||||
'/notifications/statistics?day={}'.format(datetime.utcnow().isoformat()),
|
||||
headers=[auth_header]
|
||||
)
|
||||
|
||||
|
||||
@@ -68,43 +68,3 @@ def test_process_sms_response_returns_error_for_unknown_status():
|
||||
success, error = process_sms_client_response(status='000', reference=str(uuid.uuid4()), client_name='Firetext')
|
||||
assert success is None
|
||||
assert error == "{} callback failed: status {} not found.".format('Firetext', '000')
|
||||
|
||||
|
||||
def test_process_sms_response_updates_notification_stats_for_valid_request(notify_db,
|
||||
notify_db_session,
|
||||
sample_notification):
|
||||
stats = NotificationStatistics.query.all()
|
||||
assert len(stats) == 1
|
||||
assert stats[0].sms_requested == 1
|
||||
assert stats[0].sms_delivered == 0
|
||||
assert stats[0].sms_failed == 0
|
||||
success, error = process_sms_client_response(status='0', reference=str(sample_notification.id),
|
||||
client_name='Firetext')
|
||||
assert error is None
|
||||
assert success == "{} callback succeeded. reference {} updated".format('Firetext', sample_notification.id)
|
||||
stats = NotificationStatistics.query.all()
|
||||
assert len(stats) == 1
|
||||
assert stats[0].sms_requested == 1
|
||||
assert stats[0].sms_delivered == 1
|
||||
assert stats[0].sms_failed == 0
|
||||
|
||||
|
||||
def test_process_sms_response_updates_notification_stats_for_valid_request_with_failed_status(notify_api,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_notification):
|
||||
with notify_api.test_request_context():
|
||||
stats = NotificationStatistics.query.all()
|
||||
assert len(stats) == 1
|
||||
assert stats[0].sms_requested == 1
|
||||
assert stats[0].sms_delivered == 0
|
||||
assert stats[0].sms_failed == 0
|
||||
success, error = process_sms_client_response(status='1', reference=str(sample_notification.id),
|
||||
client_name='Firetext')
|
||||
assert success == "{} callback succeeded. reference {} updated".format('Firetext', sample_notification.id)
|
||||
assert error is None
|
||||
stats = NotificationStatistics.query.all()
|
||||
assert len(stats) == 1
|
||||
assert stats[0].sms_requested == 1
|
||||
assert stats[0].sms_delivered == 0
|
||||
assert stats[0].sms_failed == 1
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from datetime import datetime, timedelta
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
Reference in New Issue
Block a user