From ca2ff00931202dfe7ed3c2979f4d314be7c551a2 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Fri, 29 Apr 2022 16:29:09 +0100 Subject: [PATCH] Rename monthly helper function to match annual one --- app/main/views/dashboard.py | 8 ++++---- tests/app/main/views/test_dashboard.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 3fff2b36f..4d4605771 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -139,7 +139,7 @@ def usage(service_id): return render_template( 'views/usage.html', - months=list(get_free_paid_breakdown_for_billable_units( + months=list(get_monthly_usage_breakdown( year, free_sms_allowance, units @@ -404,10 +404,10 @@ def get_usage_breakdown_by_type(usage, notification_type): return [row for row in usage if row['notification_type'] == notification_type] -def get_free_paid_breakdown_for_billable_units(year, free_sms_fragment_limit, billing_units): +def get_monthly_usage_breakdown(year, free_sms_fragment_limit, monthly_usage): cumulative = 0 - sms_units = [x for x in billing_units if x['notification_type'] == 'sms'] - letter_units = [x for x in billing_units if x['notification_type'] == 'letter'] + sms_units = [x for x in monthly_usage if x['notification_type'] == 'sms'] + letter_units = [x for x in monthly_usage if x['notification_type'] == 'letter'] for month in get_months_for_financial_year(year): previous_cumulative = cumulative monthly_usage = get_sum_billing_units(sms_units, month) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index d5d7f85a4..8271b2397 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -12,7 +12,7 @@ from app.main.views.dashboard import ( aggregate_template_usage, format_monthly_stats_to_list, get_dashboard_totals, - get_free_paid_breakdown_for_billable_units, + get_monthly_usage_breakdown, get_tuples_of_financial_years, ) from tests import ( @@ -1576,10 +1576,10 @@ def test_aggregate_status_types(dict_in, expected_failed, expected_requested): (freeze_time("2017-01-01 11:09:00.061258"), 10) ] ) -def test_get_free_paid_breakdown_for_billable_units(now, expected_number_of_months): +def test_get_monthly_usage_breakdown(now, expected_number_of_months): sms_allowance = 250000 with now: - billing_units = get_free_paid_breakdown_for_billable_units( + breakdown = get_monthly_usage_breakdown( 2016, sms_allowance, [ { 'month': 'April', 'international': False, 'rate_multiplier': 1, @@ -1599,7 +1599,8 @@ def test_get_free_paid_breakdown_for_billable_units(now, expected_number_of_mont }, ] ) - assert list(billing_units) == [ + + assert list(breakdown) == [ { 'sms_free_count': 100000, 'name': 'April',