Collect organisation type

So that we can default services to their appropriate text allowance, we
need to find out what sector they're in. So let's start collecting that
from teams as they create new services.

I think Central/Local/NHS are the right options, but these can be easily
changed if not.
This commit is contained in:
Chris Hill-Scott
2017-10-04 11:49:32 +01:00
parent 9b06f2da23
commit 9453f301d2
8 changed files with 104 additions and 21 deletions

View File

@@ -20,7 +20,7 @@ def test_get_should_render_add_service_template(
):
response = logged_in_client.get(url_for('main.add_service'))
assert response.status_code == 200
assert 'Which service do you want to set up notifications for?' in response.get_data(as_text=True)
assert 'About your service' in response.get_data(as_text=True)
def test_should_add_service_and_redirect_to_tour_when_no_services(
@@ -33,10 +33,15 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
):
response = logged_in_client.post(
url_for('main.add_service'),
data={'name': 'testing the post'})
data={
'name': 'testing the post',
'organisation_type': 'local',
}
)
assert mock_get_services_with_no_services.called
mock_create_service.assert_called_once_with(
service_name='testing the post',
organisation_type='local',
message_limit=app_.config['DEFAULT_SERVICE_LIMIT'],
restricted=True,
user_id=api_user_active.id,
@@ -72,10 +77,15 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
):
response = logged_in_client.post(
url_for('main.add_service'),
data={'name': 'testing the post'})
data={
'name': 'testing the post',
'organisation_type': 'central',
}
)
assert mock_get_services.called
mock_create_service.assert_called_once_with(
service_name='testing the post',
organisation_type='central',
message_limit=app_.config['DEFAULT_SERVICE_LIMIT'],
restricted=True,
user_id=api_user_active.id,
@@ -99,7 +109,13 @@ def test_should_return_form_errors_with_duplicate_service_name_regardless_of_cas
logged_in_client,
mock_create_duplicate_service,
):
response = logged_in_client.post(url_for('main.add_service'), data={'name': 'SERVICE ONE'})
response = logged_in_client.post(
url_for('main.add_service'),
data={
'name': 'SERVICE ONE',
'organisation_type': 'central',
},
)
assert response.status_code == 200
assert 'This service name is already in use' in response.get_data(as_text=True)

View File

@@ -43,3 +43,38 @@ def test_client_only_updates_allowed_attributes(mocker):
with pytest.raises(TypeError) as error:
ServiceAPIClient().update_service('service_id', foo='bar')
assert str(error.value) == 'Not allowed to update service attributes: foo'
def test_client_creates_service_with_correct_data(
mocker,
active_user_with_permissions,
fake_uuid,
):
client = ServiceAPIClient()
mock_post = mocker.patch.object(client, 'post')
mocker.patch('app.notify_client.current_user', id='123')
client.create_service(
service_name='My first service',
organisation_type='central_government',
message_limit=1,
restricted=True,
user_id=fake_uuid,
email_from='test@example.com',
)
mock_post.assert_called_once_with(
'/service',
dict(
# Autogenerated arguments
created_by='123',
active=True,
# service_name argument is coerced to name
name='My first service',
# The rest pass through with the same names
organisation_type='central_government',
message_limit=1,
restricted=True,
user_id=fake_uuid,
email_from='test@example.com',
),
)

View File

@@ -488,7 +488,7 @@ def mock_get_service_with_letters(mocker, api_user_active):
@pytest.fixture(scope='function')
def mock_create_service(mocker):
def _create(service_name, message_limit, restricted, user_id, email_from):
def _create(service_name, organisation_type, message_limit, restricted, user_id, email_from):
service = service_json(
101, service_name, [user_id], message_limit=message_limit, restricted=restricted, email_from=email_from)
return service['id']
@@ -499,7 +499,7 @@ def mock_create_service(mocker):
@pytest.fixture(scope='function')
def mock_create_duplicate_service(mocker):
def _create(service_name, message_limit, restricted, user_id, email_from):
def _create(service_name, organisation_type, message_limit, restricted, user_id, email_from):
json_mock = Mock(return_value={'message': {'name': ["Duplicate service name '{}'".format(service_name)]}})
resp_mock = Mock(status_code=400, json=json_mock)
http_error = HTTPError(response=resp_mock, message="Default message")