mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
add new daily sms provider volume report
code generally lifted almost exactly from the daily_volumes_report, but per provider and only for SMS.
This commit is contained in:
@@ -10,6 +10,7 @@ from app.dao.fact_billing_dao import (
|
||||
delete_billing_data_for_service_for_day,
|
||||
fetch_billing_data_for_day,
|
||||
fetch_billing_totals_for_year,
|
||||
fetch_daily_sms_provider_volumes_for_platform,
|
||||
fetch_daily_volumes_for_platform,
|
||||
fetch_letter_costs_and_totals_for_all_services,
|
||||
fetch_letter_line_items_for_all_services,
|
||||
@@ -856,6 +857,84 @@ def test_fetch_daily_volumes_for_platform(
|
||||
assert results[1].letter_sheet_totals == 40
|
||||
|
||||
|
||||
def test_fetch_daily_sms_provider_volumes_for_platform_groups_values_by_provider(
|
||||
notify_db_session,
|
||||
):
|
||||
services = [
|
||||
create_service(service_name='a'),
|
||||
create_service(service_name='b')
|
||||
]
|
||||
templates = [
|
||||
create_template(services[0]),
|
||||
create_template(services[1])
|
||||
]
|
||||
|
||||
create_ft_billing('2022-02-01', templates[0], provider='foo', notifications_sent=1, billable_unit=2)
|
||||
create_ft_billing('2022-02-01', templates[1], provider='foo', notifications_sent=4, billable_unit=8)
|
||||
|
||||
create_ft_billing('2022-02-01', templates[0], provider='bar', notifications_sent=16, billable_unit=32)
|
||||
create_ft_billing('2022-02-01', templates[1], provider='bar', notifications_sent=64, billable_unit=128)
|
||||
|
||||
results = fetch_daily_sms_provider_volumes_for_platform(start_date='2022-02-01', end_date='2022-02-01')
|
||||
|
||||
assert len(results) == 2
|
||||
assert results[0].provider == 'bar'
|
||||
assert results[0].sms_totals == 80
|
||||
assert results[0].sms_fragment_totals == 160
|
||||
|
||||
assert results[1].provider == 'foo'
|
||||
assert results[1].sms_totals == 5
|
||||
assert results[1].sms_fragment_totals == 10
|
||||
|
||||
|
||||
def test_fetch_daily_sms_provider_volumes_for_platform_for_platform_calculates_chargeable_units_and_costs(
|
||||
sample_template,
|
||||
):
|
||||
create_ft_billing('2022-02-01', sample_template, rate_multiplier=3, rate=1.5, notifications_sent=1, billable_unit=2)
|
||||
|
||||
results = fetch_daily_sms_provider_volumes_for_platform(start_date='2022-02-01', end_date='2022-02-01')
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].sms_totals == 1
|
||||
assert results[0].sms_fragment_totals == 2
|
||||
assert results[0].sms_chargeable_units == 6
|
||||
assert results[0].sms_cost == 9
|
||||
|
||||
|
||||
def test_fetch_daily_sms_provider_volumes_for_platform_for_platform_searches_dates_inclusively(sample_template):
|
||||
# too early
|
||||
create_ft_billing('2022-02-02', sample_template)
|
||||
|
||||
# just right
|
||||
create_ft_billing('2022-02-03', sample_template)
|
||||
create_ft_billing('2022-02-04', sample_template)
|
||||
create_ft_billing('2022-02-05', sample_template)
|
||||
|
||||
# too late
|
||||
create_ft_billing('2022-02-06', sample_template)
|
||||
|
||||
results = fetch_daily_sms_provider_volumes_for_platform(start_date='2022-02-03', end_date='2022-02-05')
|
||||
|
||||
assert len(results) == 3
|
||||
assert results[0].bst_date == date(2022, 2, 3)
|
||||
assert results[-1].bst_date == date(2022, 2, 5)
|
||||
|
||||
|
||||
def test_fetch_daily_sms_provider_volumes_for_platform_for_platform_only_returns_sms(
|
||||
sample_template,
|
||||
sample_email_template,
|
||||
sample_letter_template
|
||||
):
|
||||
create_ft_billing('2022-02-01', sample_template, notifications_sent=1)
|
||||
create_ft_billing('2022-02-01', sample_email_template, notifications_sent=2)
|
||||
create_ft_billing('2022-02-01', sample_letter_template, notifications_sent=4)
|
||||
|
||||
results = fetch_daily_sms_provider_volumes_for_platform(start_date='2022-02-01', end_date='2022-02-01')
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].sms_totals == 1
|
||||
|
||||
|
||||
def test_fetch_volumes_by_service(notify_db_session):
|
||||
set_up_usage_data(datetime(2022, 2, 1))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user