mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Got tests to use OrganizationType everywhere now.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -8,6 +8,7 @@ from app.dao.annual_billing_dao import (
|
||||
set_default_free_allowance_for_service,
|
||||
)
|
||||
from app.dao.date_util import get_current_calendar_year_start_year
|
||||
from app.enums import OrganizationType
|
||||
from app.models import AnnualBilling
|
||||
from tests.app.db import create_annual_billing, create_service
|
||||
|
||||
@@ -114,7 +115,7 @@ def test_set_default_free_allowance_for_service_updates_existing_year(sample_ser
|
||||
assert annual_billing[0].service_id == sample_service.id
|
||||
assert annual_billing[0].free_sms_fragment_limit == 150000
|
||||
|
||||
sample_service.organization_type = "federal"
|
||||
sample_service.organization_type = OrganizationType.FEDERAL
|
||||
|
||||
set_default_free_allowance_for_service(service=sample_service, year_start=None)
|
||||
annual_billing = AnnualBilling.query.all()
|
||||
|
||||
@@ -16,6 +16,7 @@ from app.dao.organization_dao import (
|
||||
dao_get_users_for_organization,
|
||||
dao_update_organization,
|
||||
)
|
||||
from app.enums import OrganizationType
|
||||
from app.models import Organization, Service
|
||||
from tests.app.db import (
|
||||
create_domain,
|
||||
@@ -62,7 +63,7 @@ def test_update_organization(notify_db_session):
|
||||
|
||||
data = {
|
||||
"name": "new name",
|
||||
"organization_type": "state",
|
||||
"organization_type": OrganizationType.STATE,
|
||||
"agreement_signed": True,
|
||||
"agreement_signed_at": datetime.datetime.utcnow(),
|
||||
"agreement_signed_by_id": user.id,
|
||||
@@ -138,8 +139,8 @@ def test_update_organization_does_not_update_the_service_if_certain_attributes_n
|
||||
):
|
||||
email_branding = create_email_branding()
|
||||
|
||||
sample_service.organization_type = "state"
|
||||
sample_organization.organization_type = "federal"
|
||||
sample_service.organization_type = OrganizationType.STATE
|
||||
sample_organization.organization_type = OrganizationType.FEDERAL
|
||||
sample_organization.email_branding = email_branding
|
||||
|
||||
sample_organization.services.append(sample_service)
|
||||
@@ -151,8 +152,8 @@ def test_update_organization_does_not_update_the_service_if_certain_attributes_n
|
||||
|
||||
assert sample_organization.name == "updated org name"
|
||||
|
||||
assert sample_organization.organization_type == "federal"
|
||||
assert sample_service.organization_type == "state"
|
||||
assert sample_organization.organization_type == OrganizationType.FEDERAL
|
||||
assert sample_service.organization_type == OrganizationType.STATE
|
||||
|
||||
assert sample_organization.email_branding == email_branding
|
||||
assert sample_service.email_branding is None
|
||||
@@ -162,22 +163,22 @@ def test_update_organization_updates_the_service_org_type_if_org_type_is_provide
|
||||
sample_service,
|
||||
sample_organization,
|
||||
):
|
||||
sample_service.organization_type = "state"
|
||||
sample_organization.organization_type = "state"
|
||||
sample_service.organization_type = OrganizationType.STATE
|
||||
sample_organization.organization_type = OrganizationType.STATE
|
||||
|
||||
sample_organization.services.append(sample_service)
|
||||
db.session.commit()
|
||||
|
||||
dao_update_organization(sample_organization.id, organization_type="federal")
|
||||
dao_update_organization(sample_organization.id, organization_type=OrganizationType.FEDERAL)
|
||||
|
||||
assert sample_organization.organization_type == "federal"
|
||||
assert sample_service.organization_type == "federal"
|
||||
assert sample_organization.organization_type == OrganizationType.FEDERAL
|
||||
assert sample_service.organization_type == OrganizationType.FEDERAL
|
||||
assert (
|
||||
Service.get_history_model()
|
||||
.query.filter_by(id=sample_service.id, version=2)
|
||||
.one()
|
||||
.organization_type
|
||||
== "federal"
|
||||
== OrganizationType.FEDERAL
|
||||
)
|
||||
|
||||
|
||||
@@ -217,8 +218,8 @@ def test_update_organization_does_not_override_service_branding(
|
||||
def test_add_service_to_organization(sample_service, sample_organization):
|
||||
assert sample_organization.services == []
|
||||
|
||||
sample_service.organization_type = "federal"
|
||||
sample_organization.organization_type = "state"
|
||||
sample_service.organization_type = OrganizationType.FEDERAL
|
||||
sample_organization.organization_type = OrganizationType.STATE
|
||||
|
||||
dao_add_service_to_organization(sample_service, sample_organization.id)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ from app.dao.services_dao import (
|
||||
get_services_by_partial_name,
|
||||
)
|
||||
from app.dao.users_dao import create_user_code, save_model_user
|
||||
from app.enums import KeyType
|
||||
from app.enums import KeyType, OrganizationType
|
||||
from app.models import (
|
||||
ApiKey,
|
||||
InvitedUser,
|
||||
@@ -85,7 +85,7 @@ def test_create_service(notify_db_session):
|
||||
email_from="email_from",
|
||||
message_limit=1000,
|
||||
restricted=False,
|
||||
organization_type="federal",
|
||||
organization_type=OrganizationType.FEDERAL,
|
||||
created_by=user,
|
||||
)
|
||||
dao_create_service(service, user)
|
||||
@@ -97,7 +97,7 @@ def test_create_service(notify_db_session):
|
||||
assert service_db.prefix_sms is True
|
||||
assert service.active is True
|
||||
assert user in service_db.users
|
||||
assert service_db.organization_type == "federal"
|
||||
assert service_db.organization_type == OrganizationType.FEDERAL
|
||||
assert not service.organization_id
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_create_service_with_organization(notify_db_session):
|
||||
user = create_user(email="local.authority@local-authority.gov.uk")
|
||||
organization = create_organization(
|
||||
name="Some local authority",
|
||||
organization_type="state",
|
||||
organization_type=OrganizationType.STATE,
|
||||
domains=["local-authority.gov.uk"],
|
||||
)
|
||||
assert Service.query.count() == 0
|
||||
@@ -114,7 +114,7 @@ def test_create_service_with_organization(notify_db_session):
|
||||
email_from="email_from",
|
||||
message_limit=1000,
|
||||
restricted=False,
|
||||
organization_type="federal",
|
||||
organization_type=OrganizationType.FEDERAL,
|
||||
created_by=user,
|
||||
)
|
||||
dao_create_service(service, user)
|
||||
@@ -127,7 +127,7 @@ def test_create_service_with_organization(notify_db_session):
|
||||
assert service_db.prefix_sms is True
|
||||
assert service.active is True
|
||||
assert user in service_db.users
|
||||
assert service_db.organization_type == "state"
|
||||
assert service_db.organization_type == OrganizationType.STATE
|
||||
assert service.organization_id == organization.id
|
||||
assert service.organization == organization
|
||||
|
||||
@@ -136,7 +136,7 @@ def test_fetch_service_by_id_with_api_keys(notify_db_session):
|
||||
user = create_user(email="local.authority@local-authority.gov.uk")
|
||||
organization = create_organization(
|
||||
name="Some local authority",
|
||||
organization_type="state",
|
||||
organization_type=OrganizationType.STATE,
|
||||
domains=["local-authority.gov.uk"],
|
||||
)
|
||||
assert Service.query.count() == 0
|
||||
@@ -145,7 +145,7 @@ def test_fetch_service_by_id_with_api_keys(notify_db_session):
|
||||
email_from="email_from",
|
||||
message_limit=1000,
|
||||
restricted=False,
|
||||
organization_type="federal",
|
||||
organization_type=OrganizationType.FEDERAL,
|
||||
created_by=user,
|
||||
)
|
||||
dao_create_service(service, user)
|
||||
@@ -158,7 +158,7 @@ def test_fetch_service_by_id_with_api_keys(notify_db_session):
|
||||
assert service_db.prefix_sms is True
|
||||
assert service.active is True
|
||||
assert user in service_db.users
|
||||
assert service_db.organization_type == "state"
|
||||
assert service_db.organization_type == OrganizationType.STATE
|
||||
assert service.organization_id == organization.id
|
||||
assert service.organization == organization
|
||||
|
||||
@@ -491,7 +491,7 @@ def test_get_all_user_services_should_return_empty_list_if_no_services_for_user(
|
||||
|
||||
@freeze_time("2019-04-23T10:00:00")
|
||||
def test_dao_fetch_live_services_data(sample_user):
|
||||
org = create_organization(organization_type="federal")
|
||||
org = create_organization(organization_type=OrganizationType.FEDERAL)
|
||||
service = create_service(go_live_user=sample_user, go_live_at="2014-04-20T10:00:00")
|
||||
sms_template = create_template(service=service)
|
||||
service_2 = create_service(
|
||||
@@ -530,7 +530,7 @@ def test_dao_fetch_live_services_data(sample_user):
|
||||
"service_id": mock.ANY,
|
||||
"service_name": "Sample service",
|
||||
"organization_name": "test_org_1",
|
||||
"organization_type": "federal",
|
||||
"organization_type": OrganizationType.FEDERAL,
|
||||
"consent_to_research": None,
|
||||
"contact_name": "Test User",
|
||||
"contact_email": "notify@digital.fake.gov",
|
||||
|
||||
Reference in New Issue
Block a user