mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Add endpoint to get billable units/financial year
`/services/ef7a665d-11a4-425a-a180-a67ca00b69d7/billable-units?year=2016` Pretty much just passes through to the DAO layer. Validates that year is: - present (there’s no need for unbounded queries on this endpoint) - an integer
This commit is contained in:
@@ -1300,3 +1300,27 @@ def test_get_detailed_services_only_includes_todays_notifications(notify_db, not
|
||||
'email': {'delivered': 0, 'failed': 0, 'requested': 0},
|
||||
'sms': {'delivered': 0, 'failed': 0, 'requested': 2}
|
||||
}
|
||||
|
||||
|
||||
@freeze_time('2012-12-12T12:00:01')
|
||||
def test_get_notification_billable_unit_count(client, notify_db, notify_db_session):
|
||||
notification = create_sample_notification(notify_db, notify_db_session)
|
||||
response = client.get(
|
||||
'/service/{}/billable-units?year=2012'.format(notification.service_id),
|
||||
headers=[create_authorization_header(service_id=notification.service_id)]
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == {
|
||||
'December': 1
|
||||
}
|
||||
|
||||
|
||||
def test_get_notification_billable_unit_count_missing_year(client, sample_service):
|
||||
response = client.get(
|
||||
'/service/{}/billable-units'.format(sample_service.id),
|
||||
headers=[create_authorization_header(service_id=sample_service.id)]
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert json.loads(response.get_data(as_text=True)) == {
|
||||
'message': 'No valid year provided', 'result': 'error'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user