mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Let NHS Trusts and CCGs choose own organisation
All we do via support is ask which organisation they work for and manually assign their service to it. This commit makes that process self service. We think we have all the trusts and clinical commissioning groups loaded into the database now. This will make the go live process smoother for these teams.
This commit is contained in:
@@ -165,7 +165,7 @@ def test_create_new_organisation_validates(
|
||||
('central', None, 403),
|
||||
('nhs_gp', organisation_json(organisation_type='nhs_gp'), 403),
|
||||
))
|
||||
def test_only_gps_can_create_own_organisations(
|
||||
def test_gps_can_create_own_organisations(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
@@ -193,6 +193,62 @@ def test_only_gps_can_create_own_organisations(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, organisation, expected_status', (
|
||||
('nhs_local', None, 200),
|
||||
('nhs_gp', None, 403),
|
||||
('central', None, 403),
|
||||
('nhs_local', organisation_json(organisation_type='nhs_local'), 403),
|
||||
))
|
||||
def test_nhs_local_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)
|
||||
mocker.patch(
|
||||
'app.models.organisation.Organisations.client',
|
||||
return_value=[
|
||||
organisation_json('t1', 'Trust 1', organisation_type='nhs_local'),
|
||||
organisation_json('t2', 'Trust 2', organisation_type='nhs_local'),
|
||||
organisation_json('gp1', 'GP 1', organisation_type='nhs_gp'),
|
||||
organisation_json('c1', 'Central 1'),
|
||||
],
|
||||
)
|
||||
service_one['organisation_type'] = organisation_type
|
||||
|
||||
page = client_request.get(
|
||||
'.add_organisation_from_nhs_local_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
|
||||
if expected_status == 403:
|
||||
return
|
||||
|
||||
assert normalize_spaces(page.select_one('main p').text) == (
|
||||
'Which NHS Trust or Clinical Commissioning Group do you work for?'
|
||||
)
|
||||
assert page.select_one('[data-module=live-search]')['data-targets'] == (
|
||||
'.multiple-choice'
|
||||
)
|
||||
assert [
|
||||
(
|
||||
normalize_spaces(radio.select_one('label').text),
|
||||
radio.select_one('input')['value']
|
||||
)
|
||||
for radio in page.select('.multiple-choice')
|
||||
] == [
|
||||
('Trust 1', 't1'),
|
||||
('Trust 2', 't2'),
|
||||
]
|
||||
assert normalize_spaces(page.select_one('.js-stick-at-bottom-when-scrolling button').text) == (
|
||||
'Continue'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('data, expected_service_name', (
|
||||
(
|
||||
{
|
||||
@@ -278,6 +334,38 @@ def test_validation_of_gps_creating_organisations(
|
||||
assert normalize_spaces(page.select_one('.error-message').text) == expected_error
|
||||
|
||||
|
||||
def test_nhs_local_assigns_to_selected_organisation(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_update_service_organisation,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_service_organisation', return_value=None)
|
||||
mocker.patch(
|
||||
'app.models.organisation.Organisations.client',
|
||||
return_value=[
|
||||
organisation_json(ORGANISATION_ID, 'Trust 1', organisation_type='nhs_local'),
|
||||
],
|
||||
)
|
||||
service_one['organisation_type'] = 'nhs_local'
|
||||
|
||||
client_request.post(
|
||||
'.add_organisation_from_nhs_local_service',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data={
|
||||
'organisations': ORGANISATION_ID,
|
||||
},
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True
|
||||
)
|
||||
)
|
||||
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,22 +108,28 @@ def test_show_agreement_page(
|
||||
assert link['href'] == url()
|
||||
|
||||
|
||||
def test_unknown_gps_are_redirected(
|
||||
@pytest.mark.parametrize('org_type, expected_endpoint', (
|
||||
('nhs_gp', 'main.add_organisation_from_gp_service'),
|
||||
('nhs_local', 'main.add_organisation_from_nhs_local_service'),
|
||||
))
|
||||
def test_unknown_gps_and_trusts_are_redirected(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
mock_has_jobs,
|
||||
service_one,
|
||||
org_type,
|
||||
expected_endpoint,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_service_organisation', return_value=None)
|
||||
service_one['organisation_id'] = None
|
||||
service_one['organisation_type'] = 'nhs_gp'
|
||||
service_one['organisation_type'] = org_type
|
||||
client_request.get(
|
||||
'main.service_agreement',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
'main.add_organisation_from_gp_service',
|
||||
expected_endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_external=True,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user