Add extra fields to create/update organisation

This commit is contained in:
Chris Hill-Scott
2019-07-03 14:53:20 +01:00
parent 1ebd147ad0
commit a4ae534f87
3 changed files with 57 additions and 12 deletions

View File

@@ -133,7 +133,9 @@ def test_get_organisation_by_domain(
def test_post_create_organisation(admin_request, notify_db_session):
data = {
'name': 'test organisation',
'active': True
'active': True,
'crown': False,
'organisation_type': 'local',
}
response = admin_request.post(
@@ -146,13 +148,18 @@ def test_post_create_organisation(admin_request, notify_db_session):
assert data['name'] == response['name']
assert data['active'] == response['active']
assert data['crown'] == response['crown']
assert data['organisation_type'] == response['organisation_type']
assert len(organisation) == 1
def test_post_create_organisation_existing_name_raises_400(admin_request, sample_organisation):
data = {
'name': sample_organisation.name,
'active': True
'active': True,
'crown': True,
'organisation_type': 'central',
}
response = admin_request.post(
@@ -167,11 +174,41 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample
assert response['message'] == 'Organisation name already exists'
def test_post_create_organisation_with_missing_name_gives_validation_error(admin_request, notify_db_session):
data = {
'active': False
}
@pytest.mark.parametrize('data, expected_error', (
({
'active': False,
'crown': True,
'organisation_type': 'central',
}, 'name is a required property'),
({
'active': False,
'name': 'Service name',
'organisation_type': 'central',
}, 'crown is a required property'),
({
'active': False,
'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]'),
))
def test_post_create_organisation_with_missing_name_gives_validation_error(
admin_request,
notify_db_session,
data,
expected_error,
):
response = admin_request.post(
'organisation.create_organisation',
_data=data,
@@ -180,7 +217,7 @@ def test_post_create_organisation_with_missing_name_gives_validation_error(admin
assert len(response['errors']) == 1
assert response['errors'][0]['error'] == 'ValidationError'
assert response['errors'][0]['message'] == 'name is a required property'
assert response['errors'][0]['message'] == expected_error
@pytest.mark.parametrize('agreement_signed', (
@@ -203,6 +240,7 @@ def test_post_update_organisation_updates_fields(
'crown': crown,
'agreement_signed_on_behalf_of_name': 'Firstname Lastname',
'agreement_signed_on_behalf_of_email_address': 'test@example.com',
'organisation_type': 'central',
}
assert org.agreement_signed is None
assert org.crown is None
@@ -225,6 +263,7 @@ def test_post_update_organisation_updates_fields(
assert organisation[0].domains == []
assert organisation[0].agreement_signed_on_behalf_of_name == 'Firstname Lastname'
assert organisation[0].agreement_signed_on_behalf_of_email_address == 'test@example.com'
assert organisation[0].organisation_type == 'central'
@pytest.mark.parametrize('domain_list', (