mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 00:23:12 -04:00
update test
This commit is contained in:
@@ -76,7 +76,7 @@ def get_organization_message_allowance(org_id):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_services_usage(organization, year):
|
def get_services_dashboard_data(organization, year):
|
||||||
try:
|
try:
|
||||||
dashboard_data = organizations_client.get_organization_dashboard(organization.id, year)
|
dashboard_data = organizations_client.get_organization_dashboard(organization.id, year)
|
||||||
services = dashboard_data.get("services", [])
|
services = dashboard_data.get("services", [])
|
||||||
@@ -87,7 +87,8 @@ def get_services_usage(organization, year):
|
|||||||
for service in services:
|
for service in services:
|
||||||
service["id"] = service.get("service_id")
|
service["id"] = service.get("service_id")
|
||||||
service["name"] = service.get("service_name")
|
service["name"] = service.get("service_name")
|
||||||
service["recent_template"] = service.get("recent_sms_template_name")
|
service["recent_template"] = service.get("recent_sms_template_name") or "N/A"
|
||||||
|
service["primary_contact"] = service.get("primary_contact") or "N/A"
|
||||||
|
|
||||||
emails_sent = service.get("emails_sent", 0)
|
emails_sent = service.get("emails_sent", 0)
|
||||||
sms_sent = service.get("sms_billable_units", 0)
|
sms_sent = service.get("sms_billable_units", 0)
|
||||||
@@ -118,7 +119,7 @@ def organization_dashboard(org_id):
|
|||||||
|
|
||||||
message_allowance = get_organization_message_allowance(org_id)
|
message_allowance = get_organization_message_allowance(org_id)
|
||||||
|
|
||||||
services_with_usage = get_services_usage(current_organization, year)
|
services_with_usage = get_services_dashboard_data(current_organization, year)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"views/organizations/organization/index.html",
|
"views/organizations/organization/index.html",
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ class Organization(JSONModel, SortByNameMixin):
|
|||||||
def associate_service(self, service_id):
|
def associate_service(self, service_id):
|
||||||
organizations_client.update_service_organization(service_id, self.id)
|
organizations_client.update_service_organization(service_id, self.id)
|
||||||
|
|
||||||
def services_and_usage(self, financial_year, include_all_services=False):
|
def services_and_usage(self, financial_year):
|
||||||
return organizations_client.get_services_and_usage(self.id, financial_year, include_all_services)
|
return organizations_client.get_services_and_usage(self.id, financial_year)
|
||||||
|
|
||||||
|
|
||||||
class Organizations(SerialisedModelCollection):
|
class Organizations(SerialisedModelCollection):
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ class OrganizationsClient(NotifyAdminAPIClient):
|
|||||||
def remove_user_from_organization(self, org_id, user_id):
|
def remove_user_from_organization(self, org_id, user_id):
|
||||||
return self.delete(f"/organizations/{org_id}/users/{user_id}")
|
return self.delete(f"/organizations/{org_id}/users/{user_id}")
|
||||||
|
|
||||||
def get_services_and_usage(self, org_id, year, include_all_services=False):
|
def get_services_and_usage(self, org_id, year):
|
||||||
return self.get(
|
return self.get(
|
||||||
url=f"/organizations/{org_id}/services-with-usage",
|
url=f"/organizations/{org_id}/services-with-usage",
|
||||||
params={"year": str(year), "include_all_services": str(include_all_services).lower()},
|
params={"year": str(year)},
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_organization_message_usage(self, org_id):
|
def get_organization_message_usage(self, org_id):
|
||||||
|
|||||||
@@ -104,9 +104,9 @@
|
|||||||
Live
|
Live
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ service.usage|default('N/A') }}</td>
|
<td>{{ service.usage }}</td>
|
||||||
<td>{{ service.primary_contact|default('N/A') }}</td>
|
<td>{{ service.primary_contact }}</td>
|
||||||
<td>{{ service.recent_template|default('N/A') }}</td>
|
<td>{{ service.recent_template }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ def test_organization_services_shows_live_services_and_usage(
|
|||||||
|
|
||||||
client_request.login(active_user_with_permissions)
|
client_request.login(active_user_with_permissions)
|
||||||
page = client_request.get(".organization_usage", org_id=ORGANISATION_ID)
|
page = client_request.get(".organization_usage", org_id=ORGANISATION_ID)
|
||||||
mock.assert_called_once_with(ORGANISATION_ID, 2020, False)
|
mock.assert_called_once_with(ORGANISATION_ID, 2020)
|
||||||
|
|
||||||
services = page.select("main h3")
|
services = page.select("main h3")
|
||||||
usage_rows = page.select("main .grid-col-6")
|
usage_rows = page.select("main .grid-col-6")
|
||||||
@@ -447,7 +447,7 @@ def test_organization_services_filters_by_financial_year(
|
|||||||
org_id=ORGANISATION_ID,
|
org_id=ORGANISATION_ID,
|
||||||
year=financial_year,
|
year=financial_year,
|
||||||
)
|
)
|
||||||
mock.assert_called_once_with(ORGANISATION_ID, financial_year, False)
|
mock.assert_called_once_with(ORGANISATION_ID, financial_year)
|
||||||
assert normalize_spaces(page.select_one(".pill").text) == (
|
assert normalize_spaces(page.select_one(".pill").text) == (
|
||||||
"2020 to 2021 fiscal year "
|
"2020 to 2021 fiscal year "
|
||||||
"2019 to 2020 fiscal year "
|
"2019 to 2020 fiscal year "
|
||||||
@@ -1609,7 +1609,7 @@ def test_organization_dashboard_shows_service_counts(
|
|||||||
assert "1 Suspended" in normalize_spaces(service_box.text)
|
assert "1 Suspended" in normalize_spaces(service_box.text)
|
||||||
|
|
||||||
|
|
||||||
def test_organization_dashboard_services_table_shows_usage(
|
def test_organization_dashboard_services_table(
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_organization,
|
mock_get_organization,
|
||||||
mocker,
|
mocker,
|
||||||
@@ -1642,6 +1642,7 @@ def test_organization_dashboard_services_table_shows_usage(
|
|||||||
"sms_remainder": 249500,
|
"sms_remainder": 249500,
|
||||||
"sms_cost": 42.75,
|
"sms_cost": 42.75,
|
||||||
"recent_sms_template_name": "Welcome SMS",
|
"recent_sms_template_name": "Welcome SMS",
|
||||||
|
"primary_contact": None,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"service_id": "2",
|
"service_id": "2",
|
||||||
@@ -1653,6 +1654,7 @@ def test_organization_dashboard_services_table_shows_usage(
|
|||||||
"sms_remainder": 249900,
|
"sms_remainder": 249900,
|
||||||
"sms_cost": 0,
|
"sms_cost": 0,
|
||||||
"recent_sms_template_name": "Reminder SMS",
|
"recent_sms_template_name": "Reminder SMS",
|
||||||
|
"primary_contact": None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user