Add more realistic test

Add statsd
Fix imports
This commit is contained in:
Rebecca Law
2020-02-25 17:47:03 +00:00
parent 67c64a8715
commit f7a564a17c
3 changed files with 25 additions and 12 deletions

View File

@@ -15,7 +15,8 @@ from tests.app.db import (
create_service,
create_user,
create_template,
create_ft_billing
create_ft_billing,
create_annual_billing
)
@@ -750,7 +751,9 @@ def test_get_organisation_services_usage(admin_request, notify_db_session):
service = create_service()
template = create_template(service=service)
dao_add_service_to_organisation(service=service, organisation_id=org.id)
create_ft_billing(bst_date=datetime.utcnow().date(), template=template, billable_unit=19, notifications_sent=19)
create_annual_billing(service_id=service.id, free_sms_fragment_limit=10, financial_year_start=2019)
create_ft_billing(bst_date=datetime.utcnow().date(), template=template, billable_unit=19, rate=0.060,
notifications_sent=19)
response = admin_request.get(
'organisation.get_organisation_services_usage',
organisation_id=org.id,
@@ -758,8 +761,16 @@ def test_get_organisation_services_usage(admin_request, notify_db_session):
)
assert len(response) == 1
assert len(response['services']) == 1
print(response)
assert response['services'][0]['service_id'] == str(service.id)
service_usage = response['services'][0]
assert service_usage['service_id'] == str(service.id)
assert service_usage['service_name'] == service.name
assert service_usage['chargeable_billable_sms'] == 9.0
assert service_usage['emails_sent'] == 0
assert service_usage['free_sms_limit'] == 10
assert service_usage['letter_cost'] == 0
assert service_usage['sms_billable_units'] == 19
assert service_usage['sms_remainder'] == 10
assert service_usage['sms_cost'] == 0.54
def test_get_organisation_services_usage_returns_400_if_year_is_invalid(admin_request):