mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Move edge case usage API tests down to DAO level
These tests weren't checking anything structural about the APIs beyond what's covered by the other tests. They represent edge cases that we can check at a lower level instead. It was also unclear what these tests were actually testing, as the term "all cases" is vague. Looking at the test data, there are variations in rates, multipliers and billable units for SMS and letters, which I've summarised as "variable rates". Note: I've removed part of the test data - for the first class letter rate - as it's not clearly adding anything.
This commit is contained in:
@@ -273,145 +273,3 @@ def test_get_yearly_billing_usage_summary_from_ft_billing(admin_request, notify_
|
||||
assert json_response[2]['billing_units'] == 825
|
||||
assert json_response[2]['rate'] == 0.0162
|
||||
assert json_response[2]['letter_total'] == 0
|
||||
|
||||
|
||||
def test_get_yearly_usage_by_monthly_from_ft_billing_all_cases(admin_request, notify_db_session):
|
||||
service = set_up_data_for_all_cases()
|
||||
|
||||
json_response = admin_request.get(
|
||||
'billing.get_yearly_usage_by_monthly_from_ft_billing',
|
||||
service_id=service.id,
|
||||
year=2018
|
||||
)
|
||||
|
||||
assert len(json_response) == 5
|
||||
assert json_response[0]['month'] == 'May'
|
||||
assert json_response[0]['notification_type'] == 'letter'
|
||||
assert json_response[0]['rate'] == 0.33
|
||||
assert json_response[0]['billing_units'] == 1
|
||||
assert json_response[0]['postage'] == 'second'
|
||||
|
||||
assert json_response[1]['month'] == 'May'
|
||||
assert json_response[1]['notification_type'] == 'letter'
|
||||
assert json_response[1]['rate'] == 0.36
|
||||
assert json_response[1]['billing_units'] == 1
|
||||
assert json_response[1]['postage'] == 'second'
|
||||
|
||||
assert json_response[2]['month'] == 'May'
|
||||
assert json_response[2]['notification_type'] == 'letter'
|
||||
assert json_response[2]['rate'] == 0.39
|
||||
assert json_response[2]['billing_units'] == 1
|
||||
assert json_response[2]['postage'] == 'first'
|
||||
|
||||
assert json_response[3]['month'] == 'May'
|
||||
assert json_response[3]['notification_type'] == 'sms'
|
||||
assert json_response[3]['rate'] == 0.0150
|
||||
assert json_response[3]['billing_units'] == 4
|
||||
assert json_response[3]['postage'] == 'none'
|
||||
|
||||
assert json_response[4]['month'] == 'May'
|
||||
assert json_response[4]['notification_type'] == 'sms'
|
||||
assert json_response[4]['rate'] == 0.162
|
||||
assert json_response[4]['billing_units'] == 5
|
||||
assert json_response[4]['postage'] == 'none'
|
||||
|
||||
|
||||
def test_get_yearly_billing_usage_summary_from_ft_billing_all_cases(admin_request, notify_db_session):
|
||||
service = set_up_data_for_all_cases()
|
||||
|
||||
json_response = admin_request.get(
|
||||
'billing.get_yearly_billing_usage_summary_from_ft_billing',
|
||||
service_id=service.id,
|
||||
year=2018
|
||||
)
|
||||
|
||||
assert len(json_response) == 6
|
||||
assert json_response[0]["notification_type"] == 'email'
|
||||
assert json_response[0]["billing_units"] == 1
|
||||
assert json_response[0]["rate"] == 0
|
||||
assert json_response[0]["letter_total"] == 0
|
||||
|
||||
assert json_response[1]["notification_type"] == 'letter'
|
||||
assert json_response[1]["billing_units"] == 1
|
||||
assert json_response[1]["rate"] == 0.33
|
||||
assert json_response[1]["letter_total"] == 0.33
|
||||
|
||||
assert json_response[2]["notification_type"] == 'letter'
|
||||
assert json_response[2]["billing_units"] == 1
|
||||
assert json_response[2]["rate"] == 0.36
|
||||
assert json_response[2]["letter_total"] == 0.36
|
||||
|
||||
assert json_response[3]["notification_type"] == 'letter'
|
||||
assert json_response[3]["billing_units"] == 1
|
||||
assert json_response[3]["rate"] == 0.39
|
||||
assert json_response[3]["letter_total"] == 0.39
|
||||
|
||||
assert json_response[4]["notification_type"] == 'sms'
|
||||
assert json_response[4]["billing_units"] == 4
|
||||
assert json_response[4]["rate"] == 0.0150
|
||||
assert json_response[4]["letter_total"] == 0
|
||||
|
||||
assert json_response[5]["notification_type"] == 'sms'
|
||||
assert json_response[5]["billing_units"] == 5
|
||||
assert json_response[5]["rate"] == 0.162
|
||||
assert json_response[5]["letter_total"] == 0
|
||||
|
||||
|
||||
def set_up_data_for_all_cases():
|
||||
service = create_service()
|
||||
sms_template = create_template(service=service, template_type="sms")
|
||||
email_template = create_template(service=service, template_type="email")
|
||||
letter_template = create_template(service=service, template_type="letter")
|
||||
create_ft_billing(bst_date='2018-05-16',
|
||||
template=sms_template,
|
||||
rate_multiplier=1,
|
||||
international=False,
|
||||
rate=0.162,
|
||||
billable_unit=1,
|
||||
notifications_sent=1)
|
||||
create_ft_billing(bst_date='2018-05-17',
|
||||
template=sms_template,
|
||||
rate_multiplier=2,
|
||||
international=False,
|
||||
rate=0.162,
|
||||
billable_unit=2,
|
||||
notifications_sent=1)
|
||||
create_ft_billing(bst_date='2018-05-16',
|
||||
template=sms_template,
|
||||
rate_multiplier=2,
|
||||
international=False,
|
||||
rate=0.0150,
|
||||
billable_unit=2,
|
||||
notifications_sent=1)
|
||||
create_ft_billing(bst_date='2018-05-16',
|
||||
template=email_template,
|
||||
rate_multiplier=1,
|
||||
international=False,
|
||||
rate=0,
|
||||
billable_unit=0,
|
||||
notifications_sent=1)
|
||||
create_ft_billing(bst_date='2018-05-16',
|
||||
template=letter_template,
|
||||
rate_multiplier=1,
|
||||
international=False,
|
||||
rate=0.33,
|
||||
billable_unit=1,
|
||||
notifications_sent=1,
|
||||
postage='second')
|
||||
create_ft_billing(bst_date='2018-05-17',
|
||||
template=letter_template,
|
||||
rate_multiplier=1,
|
||||
international=False,
|
||||
rate=0.36,
|
||||
billable_unit=2,
|
||||
notifications_sent=1,
|
||||
postage='second')
|
||||
create_ft_billing(bst_date='2018-05-18',
|
||||
template=letter_template,
|
||||
rate_multiplier=1,
|
||||
international=False,
|
||||
rate=0.39,
|
||||
billable_unit=3,
|
||||
notifications_sent=1,
|
||||
postage='first')
|
||||
return service
|
||||
|
||||
Reference in New Issue
Block a user