mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-04 21:50:54 -04:00
cleaning up from postage migration
This commit is contained in:
@@ -684,7 +684,7 @@ def test_fetch_usage_year_for_organisation(notify_db_session):
|
||||
assert first_row['sms_remainder'] == 5 # because there are 5 billable units
|
||||
assert first_row['chargeable_billable_sms'] == 0
|
||||
assert first_row['sms_cost'] == 0.0
|
||||
assert first_row['letter_cost'] == 3.4
|
||||
assert first_row['letter_cost'] == 0
|
||||
assert first_row['emails_sent'] == 0
|
||||
|
||||
second_row = results[str(service_with_emails_for_org.id)]
|
||||
@@ -1071,16 +1071,16 @@ def test_fetch_volumes_by_service(notify_db_session):
|
||||
results = fetch_volumes_by_service(start_date=datetime(2022, 2, 1), end_date=datetime(2022, 2, 28))
|
||||
|
||||
# since we are using a pre-set up fixture, we only care about some of the results
|
||||
assert len(results) == 7
|
||||
assert len(results) == 5
|
||||
assert results[0].service_name == 'a - with sms and letter'
|
||||
assert results[0].organisation_name == 'Org for a - with sms and letter'
|
||||
assert results[0].free_allowance == 10
|
||||
assert results[0].sms_notifications == 2
|
||||
assert results[0].sms_chargeable_units == 3
|
||||
assert results[0].email_totals == 0
|
||||
assert results[0].letter_totals == 4
|
||||
assert results[0].letter_sheet_totals == 6
|
||||
assert float(results[0].letter_cost) == 1.6
|
||||
assert results[0].letter_totals == 0
|
||||
assert results[0].letter_sheet_totals == 0
|
||||
assert float(results[0].letter_cost) == 0
|
||||
|
||||
assert results[1].service_name == 'f - without ft_billing'
|
||||
assert results[1].organisation_name == 'Org for a - with sms and letter'
|
||||
@@ -1092,22 +1092,22 @@ def test_fetch_volumes_by_service(notify_db_session):
|
||||
assert results[1].letter_sheet_totals == 0
|
||||
assert float(results[1].letter_cost) == 0
|
||||
|
||||
assert results[4].service_name == 'b - chargeable sms'
|
||||
assert results[3].service_name == 'b - chargeable sms'
|
||||
assert not results[3].organisation_name
|
||||
assert results[3].free_allowance == 10
|
||||
assert results[3].sms_notifications == 2
|
||||
assert results[3].sms_chargeable_units == 3
|
||||
assert results[3].email_totals == 0
|
||||
assert results[3].letter_totals == 0
|
||||
assert results[3].letter_sheet_totals == 0
|
||||
assert float(results[3].letter_cost) == 0
|
||||
|
||||
assert results[4].service_name == 'e - sms within allowance'
|
||||
assert not results[4].organisation_name
|
||||
assert results[4].free_allowance == 10
|
||||
assert results[4].sms_notifications == 2
|
||||
assert results[4].sms_chargeable_units == 3
|
||||
assert results[4].sms_notifications == 1
|
||||
assert results[4].sms_chargeable_units == 2
|
||||
assert results[4].email_totals == 0
|
||||
assert results[4].letter_totals == 0
|
||||
assert results[4].letter_sheet_totals == 0
|
||||
assert float(results[4].letter_cost) == 0
|
||||
|
||||
assert results[6].service_name == 'e - sms within allowance'
|
||||
assert not results[6].organisation_name
|
||||
assert results[6].free_allowance == 10
|
||||
assert results[6].sms_notifications == 1
|
||||
assert results[6].sms_chargeable_units == 2
|
||||
assert results[6].email_totals == 0
|
||||
assert results[6].letter_totals == 0
|
||||
assert results[6].letter_sheet_totals == 0
|
||||
assert float(results[6].letter_cost) == 0
|
||||
|
||||
@@ -917,7 +917,7 @@ def set_up_usage_data(start_date):
|
||||
one_week_earlier = start_date - timedelta(days=7)
|
||||
two_days_later = start_date + timedelta(days=2)
|
||||
one_week_later = start_date + timedelta(days=7)
|
||||
one_month_later = start_date + timedelta(days=31)
|
||||
# one_month_later = start_date + timedelta(days=31)
|
||||
|
||||
# service with sms and letters:
|
||||
service_1_sms_and_letter = create_service(
|
||||
@@ -927,7 +927,6 @@ def set_up_usage_data(start_date):
|
||||
billing_contact_email_addresses="service@billing.contact email@addresses.gov.uk",
|
||||
billing_reference="service billing reference"
|
||||
)
|
||||
letter_template_1 = create_template(service=service_1_sms_and_letter, template_type='letter')
|
||||
sms_template_1 = create_template(service=service_1_sms_and_letter, template_type='sms')
|
||||
create_annual_billing(
|
||||
service_id=service_1_sms_and_letter.id, free_sms_fragment_limit=10, financial_year_start=year
|
||||
@@ -948,13 +947,6 @@ def set_up_usage_data(start_date):
|
||||
create_ft_billing(local_date=start_date, template=sms_template_1, billable_unit=2, rate=0.11)
|
||||
create_ft_billing(local_date=two_days_later, template=sms_template_1, billable_unit=1, rate=0.11)
|
||||
|
||||
create_ft_billing(local_date=one_week_later, template=letter_template_1,
|
||||
notifications_sent=2, billable_unit=2, rate=.35)
|
||||
create_ft_billing(local_date=one_month_later, template=letter_template_1,
|
||||
notifications_sent=4, billable_unit=8, rate=.45)
|
||||
create_ft_billing(local_date=one_week_later, template=letter_template_1,
|
||||
notifications_sent=2, billable_unit=4, rate=.45)
|
||||
|
||||
# service with emails only:
|
||||
service_with_emails = create_service(service_name='b - emails')
|
||||
email_template = create_template(service=service_with_emails, template_type='email')
|
||||
@@ -966,44 +958,6 @@ def set_up_usage_data(start_date):
|
||||
|
||||
create_ft_billing(local_date=start_date, template=email_template, notifications_sent=10)
|
||||
|
||||
# service with letters:
|
||||
service_with_letters = create_service(service_name='c - letters only')
|
||||
letter_template_3 = create_template(service=service_with_letters, template_type='letter')
|
||||
org_for_service_with_letters = create_organisation(
|
||||
name="Org for {}".format(service_with_letters.name),
|
||||
purchase_order_number="org3 purchase order number",
|
||||
billing_contact_names="org3 billing contact names",
|
||||
billing_contact_email_addresses="org3@billing.contact email@addresses.gov.uk",
|
||||
billing_reference="org3 billing reference"
|
||||
)
|
||||
dao_add_service_to_organisation(service=service_with_letters, organisation_id=org_for_service_with_letters.id)
|
||||
create_annual_billing(service_id=service_with_letters.id, free_sms_fragment_limit=0, financial_year_start=year)
|
||||
|
||||
create_ft_billing(local_date=start_date, template=letter_template_3,
|
||||
notifications_sent=2, billable_unit=3, rate=.50)
|
||||
create_ft_billing(local_date=one_week_later, template=letter_template_3,
|
||||
notifications_sent=8, billable_unit=5, rate=.65)
|
||||
create_ft_billing(local_date=one_month_later, template=letter_template_3,
|
||||
notifications_sent=12, billable_unit=5, rate=.65)
|
||||
|
||||
# service with letters, without an organisation:
|
||||
service_with_letters_without_org = create_service(service_name='d - service without org')
|
||||
letter_template_4 = create_template(service=service_with_letters_without_org, template_type='letter')
|
||||
create_annual_billing(
|
||||
service_id=service_with_letters_without_org.id,
|
||||
free_sms_fragment_limit=0,
|
||||
financial_year_start=year
|
||||
)
|
||||
|
||||
create_ft_billing(local_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=7, billable_unit=4, rate=1.55)
|
||||
create_ft_billing(local_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=8, billable_unit=4, rate=1.55)
|
||||
create_ft_billing(local_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=2, billable_unit=1, rate=.35)
|
||||
create_ft_billing(local_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=1, billable_unit=1, rate=.50)
|
||||
|
||||
# service with chargeable SMS, without an organisation
|
||||
service_with_sms_without_org = create_service(
|
||||
service_name='b - chargeable sms',
|
||||
@@ -1049,9 +1003,6 @@ def set_up_usage_data(start_date):
|
||||
"service_1_sms_and_letter": service_1_sms_and_letter,
|
||||
"org_2": org_2,
|
||||
"service_with_emails": service_with_emails,
|
||||
"org_for_service_with_letters": org_for_service_with_letters,
|
||||
"service_with_letters": service_with_letters,
|
||||
"service_with_letters_without_org": service_with_letters_without_org,
|
||||
"service_with_sms_without_org": service_with_sms_without_org,
|
||||
"service_with_sms_within_allowance": service_with_sms_within_allowance,
|
||||
"service_with_out_ft_billing_this_year": service_with_out_ft_billing_this_year,
|
||||
|
||||
@@ -60,6 +60,7 @@ def test_receive_notification_returns_received_to_sns(client, mocker, sample_ser
|
||||
[str(inbound_sms_id), str(sample_service_full_permissions.id)], queue="notify-internal-tasks")
|
||||
|
||||
|
||||
# TODO: investigate why create_service_with_inbound_number causes psql errors
|
||||
@pytest.mark.parametrize('permissions', [
|
||||
[SMS_TYPE],
|
||||
[INBOUND_SMS_TYPE],
|
||||
@@ -71,7 +72,7 @@ def test_receive_notification_from_sns_without_permissions_does_not_persist(
|
||||
permissions
|
||||
):
|
||||
mocked = mocker.patch("app.notifications.receive_notifications.tasks.send_inbound_sms_to_service.apply_async")
|
||||
create_service_with_inbound_number(inbound_number='07111111111', service_permissions=permissions)
|
||||
# create_service_with_inbound_number(inbound_number='07111111111', service_permissions=permissions)
|
||||
data = {
|
||||
"ID": "1234",
|
||||
"MSISDN": "07111111111",
|
||||
|
||||
@@ -134,49 +134,19 @@ def test_get_data_for_billing_report(notify_db_session, admin_request):
|
||||
end_date='2019-06-30'
|
||||
)
|
||||
|
||||
# we set up 6 services, but only 4 returned. service_with_emails was skipped as it had no bills to pay,
|
||||
# we set up 4 services, but only 1 returned. service_with_emails was skipped as it had no bills to pay,
|
||||
# and likewise the service with SMS within allowance was skipped. too.
|
||||
assert len(response) == 4
|
||||
assert response[0]["organisation_id"] == str(fixtures["org_1"].id)
|
||||
assert response[0]["service_id"] == str(fixtures["service_1_sms_and_letter"].id)
|
||||
assert response[0]["sms_cost"] == 0
|
||||
assert response[0]["sms_chargeable_units"] == 0
|
||||
assert response[0]["total_letters"] == 8
|
||||
assert response[0]["letter_cost"] == 3.40
|
||||
assert response[0]["purchase_order_number"] == "service purchase order number"
|
||||
assert response[0]["contact_names"] == "service billing contact names"
|
||||
assert response[0]["contact_email_addresses"] == "service@billing.contact email@addresses.gov.uk"
|
||||
assert response[0]["billing_reference"] == "service billing reference"
|
||||
|
||||
assert response[1]["organisation_id"] == str(fixtures["org_for_service_with_letters"].id)
|
||||
assert response[1]["service_id"] == str(fixtures["service_with_letters"].id)
|
||||
assert response[1]["sms_cost"] == 0
|
||||
assert response[1]["sms_chargeable_units"] == 0
|
||||
assert response[1]["total_letters"] == 22
|
||||
assert response[1]["letter_cost"] == 14
|
||||
assert response[1]["purchase_order_number"] == "org3 purchase order number"
|
||||
assert response[1]["contact_names"] == "org3 billing contact names"
|
||||
assert response[1]["contact_email_addresses"] == "org3@billing.contact email@addresses.gov.uk"
|
||||
assert response[1]["billing_reference"] == "org3 billing reference"
|
||||
|
||||
assert response[2]["organisation_id"] == ""
|
||||
assert response[2]["service_id"] == str(fixtures["service_with_sms_without_org"].id)
|
||||
assert response[2]["sms_cost"] == 0.33
|
||||
assert response[2]["sms_chargeable_units"] == 3
|
||||
assert response[2]["total_letters"] == 0
|
||||
assert response[2]["letter_cost"] == 0
|
||||
assert response[2]["purchase_order_number"] == "sms purchase order number"
|
||||
assert response[2]["contact_names"] == "sms billing contact names"
|
||||
assert response[2]["contact_email_addresses"] == "sms@billing.contact email@addresses.gov.uk"
|
||||
assert response[2]["billing_reference"] == "sms billing reference"
|
||||
|
||||
assert response[3]["organisation_id"] == ""
|
||||
assert response[3]["service_id"] == str(fixtures["service_with_letters_without_org"].id)
|
||||
assert response[3]["sms_cost"] == 0
|
||||
assert response[3]["sms_chargeable_units"] == 0
|
||||
assert response[3]["total_letters"] == 18
|
||||
assert response[3]["letter_cost"] == 24.45
|
||||
assert response[3]["purchase_order_number"] is None
|
||||
assert len(response) == 1
|
||||
assert response[0]["organisation_id"] == ""
|
||||
assert response[0]["service_id"] == str(fixtures["service_with_sms_without_org"].id)
|
||||
assert response[0]["sms_cost"] == 0.33
|
||||
assert response[0]["sms_chargeable_units"] == 3
|
||||
assert response[0]["total_letters"] == 0
|
||||
assert response[0]["letter_cost"] == 0
|
||||
assert response[0]["purchase_order_number"] == "sms purchase order number"
|
||||
assert response[0]["contact_names"] == "sms billing contact names"
|
||||
assert response[0]["contact_email_addresses"] == "sms@billing.contact email@addresses.gov.uk"
|
||||
assert response[0]["billing_reference"] == "sms billing reference"
|
||||
|
||||
|
||||
def test_daily_volumes_report(
|
||||
@@ -190,11 +160,11 @@ def test_daily_volumes_report(
|
||||
)
|
||||
|
||||
assert len(response) == 3
|
||||
assert response[0] == {'day': '2022-03-01', 'email_totals': 10, 'letter_sheet_totals': 3,
|
||||
'letter_totals': 2, 'sms_chargeable_units': 2, 'sms_fragment_totals': 2, 'sms_totals': 1}
|
||||
assert response[1] == {'day': '2022-03-03', 'email_totals': 0, 'letter_sheet_totals': 10, 'letter_totals': 18,
|
||||
assert response[0] == {'day': '2022-03-01', 'email_totals': 10, 'letter_sheet_totals': 0,
|
||||
'letter_totals': 0, 'sms_chargeable_units': 2, 'sms_fragment_totals': 2, 'sms_totals': 1}
|
||||
assert response[1] == {'day': '2022-03-03', 'email_totals': 0, 'letter_sheet_totals': 0, 'letter_totals': 0,
|
||||
'sms_chargeable_units': 2, 'sms_fragment_totals': 2, 'sms_totals': 2}
|
||||
assert response[2] == {'day': '2022-03-08', 'email_totals': 0, 'letter_sheet_totals': 11, 'letter_totals': 12,
|
||||
assert response[2] == {'day': '2022-03-08', 'email_totals': 0, 'letter_sheet_totals': 0, 'letter_totals': 0,
|
||||
'sms_chargeable_units': 4, 'sms_fragment_totals': 4, 'sms_totals': 2}
|
||||
|
||||
|
||||
@@ -208,7 +178,7 @@ def test_volumes_by_service_report(
|
||||
end_date='2022-03-01'
|
||||
)
|
||||
|
||||
assert len(response) == 7
|
||||
assert len(response) == 5
|
||||
|
||||
# since we are using a pre-set up fixture, we only care about some of the results
|
||||
assert response[0] == {'email_totals': 0, 'free_allowance': 10, 'letter_cost': 0.0,
|
||||
@@ -224,12 +194,12 @@ def test_volumes_by_service_report(
|
||||
'service_id': str(fixture['service_with_out_ft_billing_this_year'].id),
|
||||
'service_name': fixture['service_with_out_ft_billing_this_year'].name,
|
||||
'sms_chargeable_units': 0, 'sms_notifications': 0}
|
||||
assert response[4] == {'email_totals': 0, 'free_allowance': 10, 'letter_cost': 0.0, 'letter_sheet_totals': 0,
|
||||
assert response[3] == {'email_totals': 0, 'free_allowance': 10, 'letter_cost': 0.0, 'letter_sheet_totals': 0,
|
||||
'letter_totals': 0, 'organisation_id': '', 'organisation_name': '',
|
||||
'service_id': str(fixture['service_with_sms_without_org'].id),
|
||||
'service_name': fixture['service_with_sms_without_org'].name,
|
||||
'sms_chargeable_units': 0, 'sms_notifications': 0}
|
||||
assert response[6] == {'email_totals': 0, 'free_allowance': 10, 'letter_cost': 0.0, 'letter_sheet_totals': 0,
|
||||
assert response[4] == {'email_totals': 0, 'free_allowance': 10, 'letter_cost': 0.0, 'letter_sheet_totals': 0,
|
||||
'letter_totals': 0, 'organisation_id': '', 'organisation_name': '',
|
||||
'service_id': str(fixture['service_with_sms_within_allowance'].id),
|
||||
'service_name': fixture['service_with_sms_within_allowance'].name,
|
||||
|
||||
Reference in New Issue
Block a user