more tests

This commit is contained in:
Kenneth Kehl
2024-11-15 07:21:14 -08:00
parent 0177fdc547
commit 8c7cb44399
5 changed files with 28 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
import pytest
from freezegun import freeze_time
from sqlalchemy import select
from app import db
from app.dao.annual_billing_dao import (
dao_create_or_update_annual_billing_for_year,
dao_get_free_sms_fragment_limit_for_year,
@@ -87,7 +89,7 @@ def test_set_default_free_allowance_for_service(
set_default_free_allowance_for_service(service=service, year_start=year)
annual_billing = AnnualBilling.query.all()
annual_billing = db.session.execute(select(AnnualBilling)).scalars().all()
assert len(annual_billing) == 1
assert annual_billing[0].service_id == service.id
@@ -109,7 +111,7 @@ def test_set_default_free_allowance_for_service_using_correct_year(
@freeze_time("2021-04-01 14:02:00")
def test_set_default_free_allowance_for_service_updates_existing_year(sample_service):
set_default_free_allowance_for_service(service=sample_service, year_start=None)
annual_billing = AnnualBilling.query.all()
annual_billing = db.session.execute(select(AnnualBilling)).scalars().all()
assert not sample_service.organization_type
assert len(annual_billing) == 1
assert annual_billing[0].service_id == sample_service.id
@@ -118,7 +120,7 @@ def test_set_default_free_allowance_for_service_updates_existing_year(sample_ser
sample_service.organization_type = OrganizationType.FEDERAL
set_default_free_allowance_for_service(service=sample_service, year_start=None)
annual_billing = AnnualBilling.query.all()
annual_billing = db.session.execute(select(AnnualBilling)).scalars().all()
assert len(annual_billing) == 1
assert annual_billing[0].service_id == sample_service.id
assert annual_billing[0].free_sms_fragment_limit == 150000

View File

@@ -1,3 +1,6 @@
from sqlalchemy import select
from app import db
from app.dao.email_branding_dao import (
dao_get_email_branding_by_id,
dao_get_email_branding_by_name,
@@ -27,14 +30,14 @@ def test_update_email_branding(notify_db_session):
updated_name = "new name"
create_email_branding()
email_branding = EmailBranding.query.all()
email_branding = db.session.execute(select(EmailBranding)).scalars().all()
assert len(email_branding) == 1
assert email_branding[0].name != updated_name
dao_update_email_branding(email_branding[0], name=updated_name)
email_branding = EmailBranding.query.all()
email_branding = db.session.execute(select(EmailBranding)).scalars().all()
assert len(email_branding) == 1
assert email_branding[0].name == updated_name
@@ -42,5 +45,5 @@ def test_update_email_branding(notify_db_session):
def test_email_branding_has_no_domain(notify_db_session):
create_email_branding()
email_branding = EmailBranding.query.all()
email_branding = db.session.execute(select(EmailBranding)).scalars().all()
assert not hasattr(email_branding, "domain")

View File

@@ -1,8 +1,10 @@
import uuid
import pytest
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from app import db
from app.dao.service_data_retention_dao import (
fetch_service_data_retention,
fetch_service_data_retention_by_id,
@@ -97,7 +99,7 @@ def test_insert_service_data_retention(sample_service):
days_of_retention=3,
)
results = ServiceDataRetention.query.all()
results = db.session.execute(select(ServiceDataRetention)).scalars().all()
assert len(results) == 1
assert results[0].service_id == sample_service.id
assert results[0].notification_type == NotificationType.EMAIL
@@ -131,7 +133,7 @@ def test_update_service_data_retention(sample_service):
days_of_retention=5,
)
assert updated_count == 1
results = ServiceDataRetention.query.all()
results = db.session.execute(select(ServiceDataRetention)).scalars().all()
assert len(results) == 1
assert results[0].id == data_retention.id
assert results[0].service_id == sample_service.id
@@ -150,7 +152,7 @@ def test_update_service_data_retention_does_not_update_if_row_does_not_exist(
days_of_retention=5,
)
assert updated_count == 0
assert len(ServiceDataRetention.query.all()) == 0
assert len(db.session.execute(select(ServiceDataRetention)).scalars().all()) == 0
def test_update_service_data_retention_does_not_update_row_if_data_retention_is_for_different_service(