mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
New test for notification.cost() method
Added a test that asking for a nonexistent provider_rate blows everything up. Also updated existing test to use a weirder number.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from tests.app.conftest import sample_notification, sample_provider_rate
|
||||
from app.models import (
|
||||
Notification,
|
||||
ServiceWhitelist,
|
||||
MOBILE_TYPE, EMAIL_TYPE)
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_should_not_build_service_whitelist_from_invalid_contact(recipient_type,
|
||||
|
||||
@pytest.mark.parametrize('provider, billable_units, expected_cost', [
|
||||
('mmg', 1, 3.5),
|
||||
('firetext', 2, 5),
|
||||
('firetext', 2, 0.025),
|
||||
('ses', 0, 0)
|
||||
])
|
||||
def test_calculate_cost_from_notification_billable_units(
|
||||
@@ -47,7 +47,7 @@ def test_calculate_cost_from_notification_billable_units(
|
||||
):
|
||||
provider_rates = [
|
||||
('mmg', datetime(2016, 7, 1), 1.5),
|
||||
('firetext', datetime(2016, 7, 1), 2.5),
|
||||
('firetext', datetime(2016, 7, 1), 0.0125),
|
||||
('mmg', datetime.utcnow(), 3.5),
|
||||
]
|
||||
for provider_identifier, valid_from, rate in provider_rates:
|
||||
@@ -61,3 +61,11 @@ def test_calculate_cost_from_notification_billable_units(
|
||||
|
||||
notification = sample_notification(notify_db, notify_db_session, billable_units=billable_units, sent_by=provider)
|
||||
assert notification.cost() == expected_cost
|
||||
|
||||
|
||||
def test_billable_units_without_provider_rates_entry_raises_exception(
|
||||
notify_db, notify_db_session, sample_provider_rate
|
||||
):
|
||||
notification = sample_notification(notify_db, notify_db_session, sent_by='not_a_provider')
|
||||
with pytest.raises(NoResultFound):
|
||||
notification.cost()
|
||||
|
||||
Reference in New Issue
Block a user