2016-04-05 13:49:22 +01:00
|
|
|
import uuid
|
|
|
|
|
|
2016-03-17 11:44:00 +00:00
|
|
|
from app.notify_client.statistics_api_client import StatisticsApiClient
|
|
|
|
|
|
|
|
|
|
|
2016-04-05 13:49:22 +01:00
|
|
|
def test_notifications_statistics_client_calls_correct_api_endpoint(mocker, api_user_active):
|
2016-03-17 11:44:00 +00:00
|
|
|
|
2016-04-05 13:49:22 +01:00
|
|
|
some_service_id = uuid.uuid4()
|
|
|
|
|
expected_url = '/service/{}/notifications-statistics'.format(some_service_id)
|
2016-03-17 11:44:00 +00:00
|
|
|
|
|
|
|
|
client = StatisticsApiClient()
|
2016-04-05 13:49:22 +01:00
|
|
|
|
2016-03-17 11:44:00 +00:00
|
|
|
mock_get = mocker.patch('app.notify_client.statistics_api_client.StatisticsApiClient.get')
|
|
|
|
|
|
2016-04-05 13:49:22 +01:00
|
|
|
client.get_statistics_for_service(some_service_id)
|
2016-03-17 11:44:00 +00:00
|
|
|
|
2016-04-25 11:30:09 +01:00
|
|
|
mock_get.assert_called_once_with(url=expected_url, params={})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_notifications_statistics_client_calls_correct_api_endpoint_with_params(mocker, api_user_active):
|
|
|
|
|
|
|
|
|
|
some_service_id = uuid.uuid4()
|
|
|
|
|
expected_url = '/service/{}/notifications-statistics'.format(some_service_id)
|
|
|
|
|
|
|
|
|
|
client = StatisticsApiClient()
|
|
|
|
|
|
|
|
|
|
mock_get = mocker.patch('app.notify_client.statistics_api_client.StatisticsApiClient.get')
|
|
|
|
|
|
|
|
|
|
client.get_statistics_for_service(some_service_id, limit_days=99)
|
|
|
|
|
|
|
|
|
|
mock_get.assert_called_once_with(url=expected_url, params={'limit_days': 99})
|