mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Check service has permission to send notification type.
At the moment the check_permission boolean is always false. Will set to true for usage pages
This commit is contained in:
@@ -70,6 +70,34 @@ def test_fetch_billing_data_for_today_includes_data_with_the_right_key_type(noti
|
||||
assert results[0].notifications_sent == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("notification_type", ["email", "sms", "letter"])
|
||||
def test_fetch_billing_data_for_day_only_calls_query_for_permission_type(notify_db_session, notification_type):
|
||||
service = create_service(service_permissions=[notification_type])
|
||||
email_template = create_template(service=service, template_type="email")
|
||||
sms_template = create_template(service=service, template_type="sms")
|
||||
letter_template = create_template(service=service, template_type="letter")
|
||||
create_notification(template=email_template, status='delivered')
|
||||
create_notification(template=sms_template, status='delivered')
|
||||
create_notification(template=letter_template, status='delivered')
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
results = fetch_billing_data_for_day(process_day=today.date(), check_permissions=True)
|
||||
assert len(results) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("notification_type", ["email", "sms", "letter"])
|
||||
def test_fetch_billing_data_for_day_only_calls_query_for_all_channels(notify_db_session, notification_type):
|
||||
service = create_service(service_permissions=[notification_type])
|
||||
email_template = create_template(service=service, template_type="email")
|
||||
sms_template = create_template(service=service, template_type="sms")
|
||||
letter_template = create_template(service=service, template_type="letter")
|
||||
create_notification(template=email_template, status='delivered')
|
||||
create_notification(template=sms_template, status='delivered')
|
||||
create_notification(template=letter_template, status='delivered')
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
results = fetch_billing_data_for_day(process_day=today.date(), check_permissions=False)
|
||||
assert len(results) == 3
|
||||
|
||||
|
||||
@freeze_time('2018-04-02 01:20:00')
|
||||
def test_fetch_billing_data_for_today_includes_data_with_the_right_date(notify_db_session):
|
||||
process_day = datetime(2018, 4, 1, 13, 30, 0)
|
||||
@@ -288,6 +316,7 @@ def test_fetch_billing_data_for_day_bills_correctly_for_status(notify_db_session
|
||||
assert 4 == email_results[0].notifications_sent
|
||||
assert 3 == letter_results[0].notifications_sent
|
||||
|
||||
|
||||
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