mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Need to be able to query the notification statistics for the right number of days.
If the request is for the big numbers on the activity page, then we need to use the number right number of days. Added an end point to get the data retention for the service and notification type, which is needed on the activity page to say how long the report is available for.
This commit is contained in:
@@ -35,6 +35,15 @@ def test_get_service_data_retention_returns_empty_list(client, sample_service):
|
||||
assert len(json.loads(response.get_data(as_text=True))) == 0
|
||||
|
||||
|
||||
def test_get_data_retention_for_service_notification_type(client, sample_service):
|
||||
data_retention = create_service_data_retention(service_id=sample_service.id)
|
||||
response = client.get('/service/{}/data-retention/notification-type/{}'.format(sample_service.id, 'sms'),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == data_retention.serialize()
|
||||
|
||||
|
||||
def test_get_service_data_retention_by_id(client, sample_service):
|
||||
sms_data_retention = create_service_data_retention(service_id=sample_service.id)
|
||||
create_service_data_retention(service_id=sample_service.id, notification_type='email',
|
||||
|
||||
@@ -129,11 +129,11 @@ def test_get_template_usage_by_month_returns_two_templates(admin_request, sample
|
||||
assert resp_json[2]["is_precompiled_letter"] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('today_only, stats', [
|
||||
(False, {'requested': 2, 'delivered': 1, 'failed': 0}),
|
||||
(True, {'requested': 1, 'delivered': 0, 'failed': 0})
|
||||
@pytest.mark.parametrize('today_only, limit_days, stats', [
|
||||
(False, 7, {'requested': 2, 'delivered': 1, 'failed': 0}),
|
||||
(True, 7, {'requested': 1, 'delivered': 0, 'failed': 0})
|
||||
], ids=['seven_days', 'today'])
|
||||
def test_get_service_notification_statistics(admin_request, sample_template, today_only, stats):
|
||||
def test_get_service_notification_statistics(admin_request, sample_template, today_only, limit_days, stats):
|
||||
with freeze_time('2000-01-01T12:00:00'):
|
||||
create_notification(sample_template, status='delivered')
|
||||
with freeze_time('2000-01-02T12:00:00'):
|
||||
@@ -141,7 +141,8 @@ def test_get_service_notification_statistics(admin_request, sample_template, tod
|
||||
resp = admin_request.get(
|
||||
'service.get_service_notification_statistics',
|
||||
service_id=sample_template.service_id,
|
||||
today_only=today_only
|
||||
today_only=today_only,
|
||||
limit_days=limit_days
|
||||
)
|
||||
|
||||
assert set(resp['data'].keys()) == {SMS_TYPE, EMAIL_TYPE, LETTER_TYPE}
|
||||
@@ -151,7 +152,8 @@ def test_get_service_notification_statistics(admin_request, sample_template, tod
|
||||
def test_get_service_notification_statistics_with_unknown_service(admin_request):
|
||||
resp = admin_request.get(
|
||||
'service.get_service_notification_statistics',
|
||||
service_id=uuid.uuid4()
|
||||
service_id=uuid.uuid4(),
|
||||
limit_days=7
|
||||
)
|
||||
|
||||
assert resp['data'] == {
|
||||
|
||||
Reference in New Issue
Block a user