From c3bc1d0df9e3263cad0bf6ee1de05238ccf8050b Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Fri, 29 Apr 2022 10:20:54 +0100 Subject: [PATCH] Remove redundant test data for usage DAOs This is unnecessary since we now have separate "_variable_rates" tests that check the behaviour for multiple rates explicitly for the two types of notifications it affects. --- tests/app/dao/test_ft_billing_dao.py | 51 ++++++++-------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/tests/app/dao/test_ft_billing_dao.py b/tests/app/dao/test_ft_billing_dao.py index 96b699c95..58b17b944 100644 --- a/tests/app/dao/test_ft_billing_dao.py +++ b/tests/app/dao/test_ft_billing_dao.py @@ -50,7 +50,6 @@ def set_up_yearly_data(): for dt in (date(2016, 3, 31), date(2017, 4, 1)): create_ft_billing(bst_date=dt, template=sms_template, rate=0.163) create_ft_billing(bst_date=dt, template=email_template, rate=0, billable_unit=0) - create_ft_billing(bst_date=dt, template=letter_template, rate=0.34, postage='second') create_ft_billing(bst_date=dt, template=letter_template, rate=0.31, postage='second') start_date = date(2016, 4, 1) @@ -61,7 +60,6 @@ def set_up_yearly_data(): create_ft_billing(bst_date=dt, template=sms_template, rate=0.162) create_ft_billing(bst_date=dt, template=email_template, rate=0, billable_unit=0) - create_ft_billing(bst_date=dt, template=letter_template, rate=0.33, postage='second') create_ft_billing(bst_date=dt, template=letter_template, rate=0.30, postage='second') return service @@ -429,7 +427,7 @@ def test_fetch_monthly_billing_for_year(notify_db_session): create_annual_billing(service_id=service.id, free_sms_fragment_limit=10, financial_year_start=2016) results = fetch_monthly_billing_for_year(service.id, 2016) - assert len(results) == 48 + assert len(results) == 36 assert str(results[0].month) == "2016-04-01" assert results[0].notification_type == 'email' @@ -451,29 +449,19 @@ def test_fetch_monthly_billing_for_year(notify_db_session): assert results[1].free_allowance_used == 0 assert results[1].charged_units == 30 - assert str(results[1].month) == "2016-04-01" - assert results[2].notification_type == 'letter' + assert str(results[2].month) == "2016-04-01" + assert results[2].notification_type == 'sms' assert results[2].notifications_sent == 30 assert results[2].billable_units == 30 assert results[2].chargeable_units == 30 - assert results[2].rate == Decimal('0.33') - assert results[2].cost == Decimal('9.9') - assert results[2].free_allowance_used == 0 - assert results[2].charged_units == 30 - - assert str(results[3].month) == "2016-04-01" - assert results[3].notification_type == 'sms' - assert results[3].notifications_sent == 30 - assert results[3].billable_units == 30 - assert results[3].chargeable_units == 30 - assert results[3].rate == Decimal('0.162') + assert results[2].rate == Decimal('0.162') # free allowance is 10, so (30 - 10) * 0.162 - assert results[3].cost == Decimal('3.24') - assert results[3].free_allowance_used == 10 - assert results[3].charged_units == 20 + assert results[2].cost == Decimal('3.24') + assert results[2].free_allowance_used == 10 + assert results[2].charged_units == 20 - assert str(results[4].month) == "2016-05-01" - assert str(results[47].month) == "2017-03-01" + assert str(results[3].month) == "2016-05-01" + assert str(results[35].month) == "2017-03-01" def test_fetch_monthly_billing_for_year_variable_rates(notify_db_session): @@ -552,7 +540,7 @@ def test_fetch_billing_totals_for_year(notify_db_session): create_annual_billing(service_id=service.id, free_sms_fragment_limit=1000, financial_year_start=2016) results = fetch_billing_totals_for_year(service_id=service.id, year=2016) - assert len(results) == 4 + assert len(results) == 3 assert results[0].notification_type == 'email' assert results[0].notifications_sent == 365 assert results[0].billable_units == 365 @@ -571,23 +559,14 @@ def test_fetch_billing_totals_for_year(notify_db_session): assert results[1].free_allowance_used == 0 assert results[1].charged_units == 365 - assert results[2].notification_type == 'letter' + assert results[2].notification_type == 'sms' assert results[2].notifications_sent == 365 assert results[2].billable_units == 365 assert results[2].chargeable_units == 365 - assert results[2].rate == Decimal('0.33') - assert results[2].cost == Decimal('120.45') - assert results[2].free_allowance_used == 0 - assert results[2].charged_units == 365 - - assert results[3].notification_type == 'sms' - assert results[3].notifications_sent == 365 - assert results[3].billable_units == 365 - assert results[3].chargeable_units == 365 - assert results[3].rate == Decimal('0.162') - assert results[3].cost == Decimal('0') - assert results[3].free_allowance_used == 365 - assert results[3].charged_units == 0 + assert results[2].rate == Decimal('0.162') + assert results[2].cost == Decimal('0') + assert results[2].free_allowance_used == 365 + assert results[2].charged_units == 0 def test_fetch_billing_totals_for_year_uses_current_annual_billing(notify_db_session):