mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-29 22:11:52 -05:00
Merge pull request #2192 from alphagov/exclude-failed-letters-from-billing
Update billing to ignore failed letters.
This commit is contained in:
@@ -15,7 +15,11 @@ from app.dao.fact_billing_dao import (
|
||||
get_rate,
|
||||
get_rates_for_billing,
|
||||
)
|
||||
from app.models import FactBilling, Notification
|
||||
from app.models import (
|
||||
FactBilling,
|
||||
Notification,
|
||||
NOTIFICATION_STATUS_TYPES,
|
||||
)
|
||||
from app.utils import convert_utc_to_bst
|
||||
from tests.app.db import (
|
||||
create_ft_billing,
|
||||
@@ -253,6 +257,26 @@ def test_fetch_billing_data_for_day_returns_list_for_given_service(notify_db_ses
|
||||
assert results[0].service_id == service.id
|
||||
|
||||
|
||||
def test_fetch_billing_data_for_day_bills_correctly_for_status(notify_db_session):
|
||||
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')
|
||||
for status in NOTIFICATION_STATUS_TYPES:
|
||||
create_notification(template=sms_template, status=status)
|
||||
create_notification(template=email_template, status=status)
|
||||
create_notification(template=letter_template, status=status)
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
results = fetch_billing_data_for_day(process_day=today, service_id=service.id)
|
||||
|
||||
sms_results = [x for x in results if x[2] == 'sms']
|
||||
email_results = [x for x in results if x[2] == 'email']
|
||||
letter_results = [x for x in results if x[2] == 'letter']
|
||||
assert 7 == sms_results[0][7]
|
||||
assert 7 == email_results[0][7]
|
||||
assert 3 == letter_results[0][7]
|
||||
|
||||
|
||||
def test_get_rates_for_billing(notify_db_session):
|
||||
create_rate(start_date=datetime.utcnow(), value=12, notification_type='email')
|
||||
create_rate(start_date=datetime.utcnow(), value=22, notification_type='sms')
|
||||
|
||||
Reference in New Issue
Block a user