mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-04 12:38:26 -04:00
Added a date range filter for the get all services end point.
When the start_date and end_date query argruments exists in the request, the query will return the results from the NotificationHistory table for the given date range. We will need to check the performance of this query, but this will only be used by the platform admin page.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import json
|
||||
import uuid
|
||||
|
||||
@@ -1363,6 +1363,25 @@ def test_get_detailed_services_only_includes_todays_notifications(notify_db, not
|
||||
}
|
||||
|
||||
|
||||
def test_get_detailed_services_for_date_range(notify_db, notify_db_session):
|
||||
from app.service.rest import get_detailed_services
|
||||
create_sample_notification(notify_db, notify_db_session, created_at=datetime.now() - timedelta(days=3))
|
||||
create_sample_notification(notify_db, notify_db_session, created_at=datetime.now() - timedelta(days=2))
|
||||
create_sample_notification(notify_db, notify_db_session, created_at=datetime.now() - timedelta(days=1))
|
||||
create_sample_notification(notify_db, notify_db_session, created_at=datetime.now())
|
||||
|
||||
start_date = (datetime.utcnow() - timedelta(days=2)).date()
|
||||
end_date = (datetime.utcnow() - timedelta(days=1)).date()
|
||||
|
||||
data = get_detailed_services(only_active=False, include_from_test_key=True,
|
||||
start_date=start_date, end_date=end_date)
|
||||
assert len(data) == 1
|
||||
assert data[0]['statistics'] == {
|
||||
'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)
|
||||
|
||||
Reference in New Issue
Block a user