mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 22:42:28 -05:00
Bill NOTIFICATION_PENDING notifications
SMS and emails may be marked as `NOTIFICATION_PENDING`. These will be billed as they will have been sent to the provider and will eventually turn to a final state such as `NOTIFICATION_DELIVERED` or `NOTIFICATION_PERMANENT_FAILURE`. This change will fix a discrepency on the billing page were the number of messages being billed was less than the number of messages reported as sent on a services dashboard when some of those messages were in a pending state. In reality, I don't think this bug would have had any longer affects for incorrect billing as messages would not stay in the pending state for too long and billing calculations would happen after that point.
This commit is contained in:
@@ -59,19 +59,20 @@ def set_up_yearly_data():
|
||||
|
||||
|
||||
def test_fetch_billing_data_for_today_includes_data_with_the_right_status(notify_db_session):
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
service = create_service()
|
||||
template = create_template(service=service, template_type="email")
|
||||
|
||||
for status in ['created', 'technical-failure']:
|
||||
create_notification(template=template, status=status)
|
||||
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
results = fetch_billing_data_for_day(today.date())
|
||||
assert results == []
|
||||
for status in ['delivered', 'sending', 'temporary-failure']:
|
||||
|
||||
for status in ['delivered', 'sending', 'temporary-failure', 'pending']:
|
||||
create_notification(template=template, status=status)
|
||||
results = fetch_billing_data_for_day(today.date())
|
||||
assert len(results) == 1
|
||||
assert results[0].notifications_sent == 3
|
||||
assert results[0].notifications_sent == 4
|
||||
|
||||
|
||||
def test_fetch_billing_data_for_today_includes_data_with_the_right_key_type(notify_db_session):
|
||||
@@ -299,8 +300,8 @@ def test_fetch_billing_data_for_day_bills_correctly_for_status(notify_db_session
|
||||
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 8 == sms_results[0][7]
|
||||
assert 8 == email_results[0][7]
|
||||
assert 3 == letter_results[0][7]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user