mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-03-12 14:22:37 -04:00
Merge pull request #1433 from alphagov/imdad-fix-call-correct-endpoint-for-billing-usage
Call the correct endpoint to retrieve yearly billing usage
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
27
tests/app/notify_client/test_billing_client.py
Normal file
27
tests/app/notify_client/test_billing_client.py
Normal file
@@ -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})
|
||||
Reference in New Issue
Block a user