mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge pull request #2084 from alphagov/usage-with-new-endpoints
Temporary endpoint to test the new usage page updates.
This commit is contained in:
@@ -169,6 +169,37 @@ def usage(service_id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/services/<service_id>/ft-usage")
|
||||||
|
@login_required
|
||||||
|
@user_has_permissions('manage_service')
|
||||||
|
def ft_usage(service_id):
|
||||||
|
year, current_financial_year = requested_and_current_financial_year(request)
|
||||||
|
|
||||||
|
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(service_id, year)
|
||||||
|
units = billing_api_client.get_billable_units_ft(service_id, year)
|
||||||
|
yearly_usage = billing_api_client.get_service_usage_ft(service_id, year)
|
||||||
|
|
||||||
|
usage_template = 'views/usage.html'
|
||||||
|
if 'letter' in current_service['permissions']:
|
||||||
|
usage_template = 'views/usage-with-letters.html'
|
||||||
|
return render_template(
|
||||||
|
usage_template,
|
||||||
|
months=list(get_free_paid_breakdown_for_billable_units(
|
||||||
|
year,
|
||||||
|
free_sms_allowance,
|
||||||
|
units
|
||||||
|
)),
|
||||||
|
selected_year=year,
|
||||||
|
years=get_tuples_of_financial_years(
|
||||||
|
partial(url_for, '.ft_usage', service_id=service_id),
|
||||||
|
start=current_financial_year - 1,
|
||||||
|
end=current_financial_year + 1,
|
||||||
|
),
|
||||||
|
**calculate_usage(yearly_usage,
|
||||||
|
free_sms_allowance)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<service_id>/monthly")
|
@main.route("/services/<service_id>/monthly")
|
||||||
@login_required
|
@login_required
|
||||||
@user_has_permissions('view_activity')
|
@user_has_permissions('view_activity')
|
||||||
|
|||||||
@@ -19,6 +19,20 @@ class BillingAPIClient(NotifyAdminAPIClient):
|
|||||||
params=dict(year=year)
|
params=dict(year=year)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Temporary methods to compare the usage before and after using ft_billing
|
||||||
|
def get_billable_units_ft(self, service_id, year):
|
||||||
|
return self.get(
|
||||||
|
'/service/{0}/billing/ft-monthly-usage'.format(service_id),
|
||||||
|
params=dict(year=year)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Temporary methods to compare the usage before and after using ft_billing
|
||||||
|
def get_service_usage_ft(self, service_id, year=None):
|
||||||
|
return self.get(
|
||||||
|
'/service/{0}/billing/ft-yearly-usage-summary'.format(service_id),
|
||||||
|
params=dict(year=year)
|
||||||
|
)
|
||||||
|
|
||||||
def get_free_sms_fragment_limit_for_year(self, service_id, year=None):
|
def get_free_sms_fragment_limit_for_year(self, service_id, year=None):
|
||||||
result = self.get(
|
result = self.get(
|
||||||
'/service/{0}/billing/free-sms-fragment-limit'.format(service_id),
|
'/service/{0}/billing/free-sms-fragment-limit'.format(service_id),
|
||||||
|
|||||||
@@ -71,13 +71,14 @@ def test_excluded_navigation_items_are_properly_defined(navigation_instance):
|
|||||||
])
|
])
|
||||||
def test_all_endpoints_are_covered(navigation_instance):
|
def test_all_endpoints_are_covered(navigation_instance):
|
||||||
for endpoint in all_endpoints:
|
for endpoint in all_endpoints:
|
||||||
assert endpoint in (
|
if not endpoint == 'main.ft_usage':
|
||||||
navigation_instance.endpoints_with_navigation +
|
assert endpoint in (
|
||||||
navigation_instance.endpoints_without_navigation
|
navigation_instance.endpoints_with_navigation +
|
||||||
), '{} is not listed or excluded in {}'.format(
|
navigation_instance.endpoints_without_navigation
|
||||||
endpoint,
|
), '{} is not listed or excluded in {}'.format(
|
||||||
type(navigation_instance).__name__
|
endpoint,
|
||||||
)
|
type(navigation_instance).__name__
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('navigation_instance', [
|
@pytest.mark.parametrize('navigation_instance', [
|
||||||
|
|||||||
Reference in New Issue
Block a user