Create a template in a folder.

This commit is contained in:
Rebecca Law
2018-11-08 15:53:33 +00:00
parent 622fdfedc9
commit 146c7915b2
6 changed files with 60 additions and 9 deletions

View File

@@ -164,3 +164,47 @@ def test_should_show_templates_folder_page(
assert page_links[index].text.strip() == expected_link
mock_get_service_templates.assert_called_once_with(SERVICE_ONE_ID)
@pytest.mark.parametrize("template_type", ["email", "sms"])
def test_add_template_by_type_should_redirect_to_add_service_template(
client_request,
service_one,
template_type,
mock_get_service_templates,
mock_get_organisations_and_services_for_user,
):
service_one['permissions'] += ['edit_folders']
client_request.post(
'main.add_template_by_type',
service_id=SERVICE_ONE_ID,
template_folder_id=PARENT_FOLDER_ID,
_data={'template_type': template_type},
_expected_redirect=url_for('main.add_service_template',
service_id=SERVICE_ONE_ID,
template_type=template_type,
template_folder_id=PARENT_FOLDER_ID,
_external=True),
)
def test_add_template_by_type_should_redirect_to_view_template_for_letter(
client_request,
service_one,
mock_get_service_templates,
mock_get_organisations_and_services_for_user,
fake_uuid,
mock_create_service_template
):
service_one['permissions'] += ['edit_folders']
service_one['permissions'] += ['letter']
client_request.post(
'main.add_template_by_type',
service_id=SERVICE_ONE_ID,
template_folder_id=PARENT_FOLDER_ID,
_data={'template_type': 'letter'},
_expected_redirect=url_for('main.view_template',
service_id=SERVICE_ONE_ID,
template_id='Untitled',
_external=True),
)

View File

@@ -1393,7 +1393,8 @@ def test_should_create_sms_template_without_downgrading_unicode_characters(
msg, # content
ANY, # service_id
ANY, # subject
ANY # process_type
ANY, # process_type
ANY, # parent_folder_id
)
assert resp.status_code == 302

View File

@@ -903,8 +903,8 @@ def mock_get_service_letter_template(mocker, content=None, subject=None):
@pytest.fixture(scope='function')
def mock_create_service_template(mocker, fake_uuid):
def _create(name, type_, content, service, subject=None, process_type=None):
template = template_json(fake_uuid, name, type_, content, service, process_type)
def _create(name, type_, content, service, subject=None, process_type=None, parent_folder_id=None):
template = template_json(fake_uuid, name, type_, content, service, process_type, parent_folder_id)
return {'data': template}
return mocker.patch(
@@ -925,7 +925,7 @@ def mock_update_service_template(mocker):
@pytest.fixture(scope='function')
def mock_create_service_template_content_too_big(mocker):
def _create(name, type_, content, service, subject=None, process_type=None):
def _create(name, type_, content, service, subject=None, process_type=None, parent_folder_id=None):
json_mock = Mock(return_value={
'message': {'content': ["Content has a character count greater than the limit of 459"]},
'result': 'error'