mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 13:38:53 -04:00
Merge branch 'master' of https://github.com/alphagov/notifications-api into add-reply-to-notifications
This commit is contained in:
@@ -1810,33 +1810,6 @@ def test_get_service_provider_aggregate_statistics(
|
||||
assert json.loads(response.get_data(as_text=True)) == expected_json
|
||||
|
||||
|
||||
def test_get_template_stats_by_month_returns_correct_data(notify_db, notify_db_session, client, sample_template):
|
||||
notification_history = partial(
|
||||
create_notification_history,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
sample_template
|
||||
)
|
||||
with freeze_time('2016-05-01T12:00:00'):
|
||||
not1 = notification_history(status='sending')
|
||||
notification_history(status='sending')
|
||||
notification_history(status='permanent-failure')
|
||||
notification_history(status='temporary-failure')
|
||||
|
||||
resp = client.get(
|
||||
'/service/{}/notifications/templates/monthly?year=2016'.format(not1.service_id),
|
||||
headers=[create_authorization_header()]
|
||||
)
|
||||
resp_json = json.loads(resp.get_data(as_text=True)).get('data')
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert resp_json["2016-05"][str(sample_template.id)]["name"] == "Template Name"
|
||||
assert resp_json["2016-05"][str(sample_template.id)]["type"] == "sms"
|
||||
assert resp_json["2016-05"][str(sample_template.id)]["counts"]["sending"] == 2
|
||||
assert resp_json["2016-05"][str(sample_template.id)]["counts"]["temporary-failure"] == 1
|
||||
assert resp_json["2016-05"][str(sample_template.id)]["counts"]["permanent-failure"] == 1
|
||||
|
||||
|
||||
@freeze_time('2017-11-11 02:00')
|
||||
def test_get_template_usage_by_month_returns_correct_data(
|
||||
notify_db,
|
||||
@@ -2048,24 +2021,6 @@ def test_get_template_usage_by_month_returns_two_templates(
|
||||
assert resp_json[2]["count"] == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize('query_string, expected_status, expected_json', [
|
||||
('?year=abcd', 400, {'message': 'Year must be a number', 'result': 'error'}),
|
||||
])
|
||||
def test_get_template_stats_by_month_returns_error_for_incorrect_year(
|
||||
client,
|
||||
sample_service,
|
||||
query_string,
|
||||
expected_status,
|
||||
expected_json
|
||||
):
|
||||
response = client.get(
|
||||
'/service/{}/notifications/templates/monthly{}'.format(sample_service.id, query_string),
|
||||
headers=[create_authorization_header()]
|
||||
)
|
||||
assert response.status_code == expected_status
|
||||
assert json.loads(response.get_data(as_text=True)) == expected_json
|
||||
|
||||
|
||||
def test_search_for_notification_by_to_field(client, notify_db, notify_db_session):
|
||||
create_notification = partial(create_sample_notification, notify_db, notify_db_session)
|
||||
notification1 = create_notification(to_field='+447700900855', normalised_to='447700900855')
|
||||
|
||||
Reference in New Issue
Block a user