mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-11 15:52:21 -05:00
Update service type and crown when service is added to organisation
This commit is contained in:
@@ -8,7 +8,7 @@ post_create_organisation_schema = {
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"active": {"type": ["boolean", "null"]},
|
||||
"crown": {"type": "boolean"},
|
||||
"crown": {"type": ["boolean", "null"]},
|
||||
"organisation_type": {"enum": ORGANISATION_TYPES},
|
||||
},
|
||||
"required": ["name", "crown", "organisation_type"]
|
||||
|
||||
@@ -158,19 +158,23 @@ def test_update_organisation_updates_the_service_org_type_if_org_type_is_provide
|
||||
|
||||
|
||||
def test_add_service_to_organisation(sample_service, sample_organisation):
|
||||
sample_service.organisation_type = 'local'
|
||||
sample_organisation.organisation_type = 'central'
|
||||
assert sample_organisation.services == []
|
||||
|
||||
sample_service.organisation_type = "central"
|
||||
sample_organisation.organisation_type = "local"
|
||||
sample_organisation.crown = False
|
||||
|
||||
dao_add_service_to_organisation(sample_service, sample_organisation.id)
|
||||
|
||||
assert len(sample_organisation.services) == 1
|
||||
assert sample_organisation.services[0].id == sample_service.id
|
||||
assert sample_organisation.services[0].organisation_type == 'central'
|
||||
|
||||
assert sample_service.organisation_type == sample_organisation.organisation_type
|
||||
assert sample_service.crown == sample_organisation.crown
|
||||
assert Service.get_history_model().query.filter_by(
|
||||
id=sample_service.id,
|
||||
version=2
|
||||
).one().organisation_type == 'central'
|
||||
).one().organisation_type == sample_organisation.organisation_type
|
||||
|
||||
|
||||
def test_add_service_to_multiple_organisation_raises_error(sample_service, sample_organisation):
|
||||
|
||||
@@ -132,11 +132,12 @@ def test_get_organisation_by_domain(
|
||||
assert response['result'] == 'error'
|
||||
|
||||
|
||||
def test_post_create_organisation(admin_request, notify_db_session):
|
||||
@pytest.mark.parametrize('crown', [True, False, None])
|
||||
def test_post_create_organisation(admin_request, notify_db_session, crown):
|
||||
data = {
|
||||
'name': 'test organisation',
|
||||
'active': True,
|
||||
'crown': False,
|
||||
'crown': crown,
|
||||
'organisation_type': 'local',
|
||||
}
|
||||
|
||||
@@ -192,20 +193,14 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample
|
||||
'name': 'Service name',
|
||||
'crown': True,
|
||||
}, 'organisation_type is a required property'),
|
||||
({
|
||||
'active': False,
|
||||
'name': 'Service name',
|
||||
'crown': None,
|
||||
'organisation_type': 'central',
|
||||
}, 'crown None is not of type boolean'),
|
||||
({
|
||||
'active': False,
|
||||
'name': 'Service name',
|
||||
'crown': False,
|
||||
'organisation_type': 'foo',
|
||||
}, 'organisation_type foo is not one of [central, local, nhs]'),
|
||||
}, 'organisation_type foo is not one of [central, local, nhs_central, nhs_local, emergency_services, school_or_college, other]'), # noqa
|
||||
))
|
||||
def test_post_create_organisation_with_missing_name_gives_validation_error(
|
||||
def test_post_create_organisation_with_missing_data_gives_validation_error(
|
||||
admin_request,
|
||||
notify_db_session,
|
||||
data,
|
||||
|
||||
Reference in New Issue
Block a user