From 4cca01a8cb25d8ea1b0461d34316235d876f8433 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Thu, 21 Apr 2022 18:23:50 +0100 Subject: [PATCH] Remove duplicate edge case test for monthly usage This doesn't change the structural behaviour of the API and can be tested just as well at a lower level. --- tests/app/billing/test_rest.py | 27 +-------------------------- tests/app/dao/test_ft_billing_dao.py | 10 +++++++--- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/tests/app/billing/test_rest.py b/tests/app/billing/test_rest.py index 7add7dc14..535654f12 100644 --- a/tests/app/billing/test_rest.py +++ b/tests/app/billing/test_rest.py @@ -1,5 +1,5 @@ from calendar import monthrange -from datetime import datetime, timedelta +from datetime import datetime import pytest from freezegun import freeze_time @@ -10,12 +10,9 @@ from app.dao.date_util import ( get_current_financial_year_start_year, get_month_start_and_end_date_in_utc, ) -from app.models import FactBilling from tests.app.db import ( create_annual_billing, create_ft_billing, - create_notification, - create_rate, create_service, create_template, ) @@ -128,28 +125,6 @@ def test_update_free_sms_fragment_limit_data(client, sample_service): assert annual_billing.free_sms_fragment_limit == 9999 -@freeze_time('2018-04-21 14:00') -def test_get_yearly_usage_by_monthly_from_ft_billing_populates_deltas(admin_request, notify_db_session): - service = create_service() - sms_template = create_template(service=service, template_type="sms") - create_rate(start_date=datetime.utcnow() - timedelta(days=1), value=0.158, notification_type='sms') - - create_notification(template=sms_template, status='delivered') - - assert FactBilling.query.count() == 0 - - json_response = admin_request.get( - 'billing.get_yearly_usage_by_monthly_from_ft_billing', - service_id=service.id, - year=2018 - ) - - assert len(json_response) == 1 - fact_billing = FactBilling.query.all() - assert len(fact_billing) == 1 - assert fact_billing[0].notification_type == 'sms' - - def set_up_monthly_data(): service = create_service() sms_template = create_template(service=service, template_type="sms") diff --git a/tests/app/dao/test_ft_billing_dao.py b/tests/app/dao/test_ft_billing_dao.py index b87907d7e..7de1d0c52 100644 --- a/tests/app/dao/test_ft_billing_dao.py +++ b/tests/app/dao/test_ft_billing_dao.py @@ -484,14 +484,18 @@ def test_fetch_monthly_billing_for_year_variable_rates(notify_db_session): @freeze_time('2018-08-01 13:30:00') def test_fetch_monthly_billing_for_year_adds_data_for_today(notify_db_session): service = create_service() - template = create_template(service=service, template_type="email") + template = create_template(service=service, template_type="sms") + + create_rate(start_date=datetime.utcnow() - timedelta(days=1), value=0.158, notification_type='sms') + for i in range(1, 32): create_ft_billing(bst_date='2018-07-{}'.format(i), template=template) + create_notification(template=template, status='delivered') assert db.session.query(FactBilling.bst_date).count() == 31 - results = fetch_monthly_billing_for_year(service_id=service.id, - year=2018) + results = fetch_monthly_billing_for_year(service_id=service.id, year=2018) + assert db.session.query(FactBilling.bst_date).count() == 32 assert len(results) == 2