From 232912ab3bcf76edf4ff43323f589d4c725f9c7e Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Thu, 17 Aug 2017 16:02:30 +0100 Subject: [PATCH] Call the correct endpoint to retrieve yearly billing usage --- app/notify_client/billing_api_client.py | 2 +- .../app/notify_client/test_billing_client.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/app/notify_client/test_billing_client.py diff --git a/app/notify_client/billing_api_client.py b/app/notify_client/billing_api_client.py index 37c930d7b..2041f74fe 100644 --- a/app/notify_client/billing_api_client.py +++ b/app/notify_client/billing_api_client.py @@ -20,6 +20,6 @@ class BillingAPIClient(NotifyAdminAPIClient): def get_service_usage(self, service_id, year=None): return self.get( - '/service/{0}/billing/yearly-usage'.format(service_id), + '/service/{0}/billing/yearly-usage-summary'.format(service_id), params=dict(year=year) ) diff --git a/tests/app/notify_client/test_billing_client.py b/tests/app/notify_client/test_billing_client.py new file mode 100644 index 000000000..250ad24cd --- /dev/null +++ b/tests/app/notify_client/test_billing_client.py @@ -0,0 +1,27 @@ +import uuid + +from app.notify_client.billing_api_client import BillingAPIClient + + +def test_get_billing_units_calls_correct_endpoint(mocker, api_user_active): + service_id = uuid.uuid4() + expected_url = '/service/{}/billing/monthly-usage'.format(service_id) + + client = BillingAPIClient() + + mock_get = mocker.patch('app.notify_client.billing_api_client.BillingAPIClient.get') + + client.get_billable_units(service_id, 2017) + mock_get.assert_called_once_with(expected_url, params={'year': 2017}) + + +def test_get_get_service_usage_calls_correct_endpoint(mocker, api_user_active): + service_id = uuid.uuid4() + expected_url = '/service/{}/billing/yearly-usage-summary'.format(service_id) + + client = BillingAPIClient() + + mock_get = mocker.patch('app.notify_client.billing_api_client.BillingAPIClient.get') + + client.get_service_usage(service_id, 2017) + mock_get.assert_called_once_with(expected_url, params={'year': 2017})