mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-23 09:29:14 -04:00
refactor
This commit is contained in:
@@ -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 = {}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user