diff --git a/app/main/views/organizations.py b/app/main/views/organizations.py index f6505e828..52acc144d 100644 --- a/app/main/views/organizations.py +++ b/app/main/views/organizations.py @@ -5,12 +5,7 @@ from functools import partial from flask import current_app, flash, redirect, render_template, request, url_for from flask_login import current_user -from app import ( - current_organization, - org_invite_api_client, - organizations_client, - service_api_client, -) +from app import current_organization, org_invite_api_client, organizations_client from app.main import main from app.main.forms import ( AdminBillingDetailsForm, @@ -69,7 +64,7 @@ def add_organization(): def get_organization_message_allowance(org_id): try: - message_usage = service_api_client.get_organization_message_usage(org_id) + message_usage = organizations_client.get_organization_message_usage(org_id) except Exception as e: current_app.logger.error(f"Error fetching organization message usage: {e}") message_usage = {} diff --git a/app/notify_client/organizations_api_client.py b/app/notify_client/organizations_api_client.py index 10d121a41..e7cca58ef 100644 --- a/app/notify_client/organizations_api_client.py +++ b/app/notify_client/organizations_api_client.py @@ -78,5 +78,10 @@ class OrganizationsClient(NotifyAdminAPIClient): params={"year": str(year)}, ) + def get_organization_message_usage(self, org_id): + return self.get( + url="/organizations/{}/message-allowance".format(org_id), + ) + organizations_client = OrganizationsClient() diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 3b238acbf..97d94cae4 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -561,11 +561,6 @@ class ServiceAPIClient(NotifyAdminAPIClient): url="service/get-service-message-ratio?service_id={0}".format(service_id), ) - def get_organization_message_usage(self, org_id): - return self.get( - url="/organizations/{0}/message-allowance".format(org_id), - ) - service_api_client = ServiceAPIClient() diff --git a/tests/app/main/views/organizations/test_organizations.py b/tests/app/main/views/organizations/test_organizations.py index ae6bc9043..c243d940f 100644 --- a/tests/app/main/views/organizations/test_organizations.py +++ b/tests/app/main/views/organizations/test_organizations.py @@ -1531,7 +1531,7 @@ def test_organization_dashboard_shows_message_usage( active_user_with_permissions, ): mock_message_usage = mocker.patch( - "app.service_api_client.get_organization_message_usage", + "app.organizations_client.get_organization_message_usage", return_value={ "messages_sent": 1000, "messages_remaining": 2000,