ensure stats returned for lifespan of service

even if they've never sent a notification for realsies
This commit is contained in:
Leo Hemsted
2016-07-28 15:24:21 +01:00
parent 8ad47481d7
commit e5b0d568fa
4 changed files with 46 additions and 9 deletions

View File

@@ -1121,3 +1121,29 @@ def test_get_detailed_service(notify_db, notify_db_session, notify_api, sample_s
assert 'statistics' in service.keys()
assert set(service['statistics'].keys()) == set(['sms', 'email'])
assert service['statistics']['sms'] == stats
@freeze_time('2016-07-28')
def test_get_weekly_notification_stats(notify_api, sample_notification):
with notify_api.test_request_context(), notify_api.test_client() as client:
resp = client.get(
'/service/{}/notifications/weekly'.format(sample_notification.service_id),
headers=[create_authorization_header()]
)
assert resp.status_code == 200
data = json.loads(resp.get_data(as_text=True))['data']
assert data == {
'2016-07-25': {
'sms': {
'requested': 1,
'delivered': 0,
'failed': 0
},
'email': {
'requested': 0,
'delivered': 0,
'failed': 0
}
}
}