mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-27 20:51:00 -04:00
Let GP surgeries create their own organisations
We have a bunch of GP surgeries who want to go live. They don’t automatically assigned to organisations. So this means a lot of back and forth to get these organisations set up, and then the service has to re-request to go live, and… it’s painful. Instead, let’s let GPs create their own organisations, by confirming the name of their organisation before going on to letting them accept the agreement.
This commit is contained in:
@@ -160,6 +160,75 @@ def test_create_new_organisation_validates(
|
||||
assert mock_create_organisation.called is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, organisation, expected_status', (
|
||||
('nhs_gp', None, 200),
|
||||
('central', None, 403),
|
||||
('nhs_gp', organisation_json(organisation_type='nhs_gp'), 403),
|
||||
))
|
||||
def test_only_gps_can_create_own_organisations(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
organisation_type,
|
||||
organisation,
|
||||
expected_status,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_service_organisation', return_value=organisation)
|
||||
service_one['organisation_type'] = organisation_type
|
||||
|
||||
page = client_request.get(
|
||||
'.add_organisation_from_gp_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
|
||||
if expected_status == 403:
|
||||
return
|
||||
|
||||
assert page.select_one('input[type=text]')['name'] == 'name'
|
||||
assert normalize_spaces(
|
||||
page.select_one('label[for=name]').text
|
||||
) == (
|
||||
'What’s your practice called?'
|
||||
)
|
||||
|
||||
|
||||
def test_gps_can_name_their_organisation(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_update_service_organisation,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_service_organisation', return_value=None)
|
||||
service_one['organisation_type'] = 'nhs_gp'
|
||||
mock_create_organisation = mocker.patch(
|
||||
'app.organisations_client.create_organisation',
|
||||
return_value=organisation_json(ORGANISATION_ID),
|
||||
)
|
||||
|
||||
client_request.post(
|
||||
'.add_organisation_from_gp_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data={
|
||||
'name': 'Dr. Example',
|
||||
},
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
|
||||
mock_create_organisation.assert_called_once_with(
|
||||
name='Dr. Example',
|
||||
organisation_type='nhs_gp',
|
||||
agreement_signed=False,
|
||||
crown=False,
|
||||
)
|
||||
mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID)
|
||||
|
||||
|
||||
def test_organisation_services_shows_live_services_only(
|
||||
client_request,
|
||||
mock_get_organisation,
|
||||
|
||||
@@ -108,6 +108,28 @@ def test_show_agreement_page(
|
||||
assert link['href'] == url()
|
||||
|
||||
|
||||
def test_unknown_gps_are_redirected(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
mock_has_jobs,
|
||||
service_one,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_service_organisation', return_value=None)
|
||||
service_one['organisation_id'] = None
|
||||
service_one['organisation_type'] = 'nhs_gp'
|
||||
client_request.get(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
'main.add_organisation_from_gp_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('crown, expected_status, expected_file_fetched, expected_file_served', (
|
||||
(
|
||||
True, 200, 'crown.pdf',
|
||||
|
||||
Reference in New Issue
Block a user