mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Add limit_days argument to statistics API client method
Allows getting notification counts for a given number of days to support services with custom data retention periods (admin dashboard page should still display counts for the last 7 days, while the notifications page displays all stored notifications).
This commit is contained in:
@@ -35,15 +35,21 @@ def test_client_gets_service(mocker):
|
||||
mock_get.assert_called_once_with('/service/foo')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('today_only', [True, False])
|
||||
def test_client_gets_service_statistics(mocker, today_only):
|
||||
@pytest.mark.parametrize('today_only, limit_days', [
|
||||
(True, None),
|
||||
(False, None),
|
||||
(False, 30),
|
||||
])
|
||||
def test_client_gets_service_statistics(mocker, today_only, limit_days):
|
||||
client = ServiceAPIClient()
|
||||
mock_get = mocker.patch.object(client, 'get', return_value={'data': {'a': 'b'}})
|
||||
|
||||
ret = client.get_service_statistics('foo', today_only)
|
||||
ret = client.get_service_statistics('foo', today_only, limit_days)
|
||||
|
||||
assert ret == {'a': 'b'}
|
||||
mock_get.assert_called_once_with('/service/foo/statistics', params={'today_only': today_only})
|
||||
mock_get.assert_called_once_with('/service/foo/statistics', params={
|
||||
'today_only': today_only, 'limit_days': limit_days
|
||||
})
|
||||
|
||||
|
||||
def test_client_only_updates_allowed_attributes(mocker):
|
||||
|
||||
Reference in New Issue
Block a user