mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-28 11:49:13 -04:00
Make error message specific to template type
This commit is contained in:
@@ -154,7 +154,7 @@ def test_for_commas_in_placeholders(
|
||||
|
||||
@pytest.mark.parametrize('msg', ['The quick brown fox', 'Thé “quick” bröwn fox\u200B'])
|
||||
def test_sms_character_validation(client, msg):
|
||||
OnlySMSCharacters()(None, _gen_mock_field(msg))
|
||||
OnlySMSCharacters(template_type='sms')(None, _gen_mock_field(msg))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('data, err_msg', [
|
||||
@@ -175,7 +175,7 @@ def test_sms_character_validation(client, msg):
|
||||
])
|
||||
def test_non_sms_character_validation(data, err_msg, client):
|
||||
with pytest.raises(ValidationError) as error:
|
||||
OnlySMSCharacters()(None, _gen_mock_field(data))
|
||||
OnlySMSCharacters(template_type='sms')(None, _gen_mock_field(data))
|
||||
|
||||
assert str(error.value) == err_msg
|
||||
|
||||
|
||||
@@ -1994,14 +1994,20 @@ def test_can_create_email_template_with_emoji(
|
||||
assert mock_create_service_template.called is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type', (
|
||||
'sms', 'broadcast'
|
||||
@pytest.mark.parametrize('template_type, expected_error', (
|
||||
('sms', (
|
||||
'You cannot use 🍜 in text messages.'
|
||||
)),
|
||||
('broadcast', (
|
||||
'You cannot use 🍜 in broadcasts.'
|
||||
)),
|
||||
))
|
||||
def test_should_not_create_sms_or_broadcast_template_with_emoji(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_create_service_template,
|
||||
template_type,
|
||||
expected_error,
|
||||
):
|
||||
service_one['permissions'] += [template_type]
|
||||
page = client_request.post(
|
||||
@@ -2017,22 +2023,37 @@ def test_should_not_create_sms_or_broadcast_template_with_emoji(
|
||||
},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert "You cannot use 🍜 in text messages." in page.text
|
||||
assert expected_error in page.text
|
||||
assert mock_create_service_template.called is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type', (
|
||||
'sms', 'broadcast'
|
||||
@pytest.mark.parametrize('template_type, expected_error', (
|
||||
('sms', (
|
||||
'You cannot use 🍔 in text messages.'
|
||||
)),
|
||||
('broadcast', (
|
||||
'You cannot use 🍔 in broadcasts.'
|
||||
)),
|
||||
))
|
||||
def test_should_not_update_sms_template_with_emoji(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_service_template,
|
||||
mock_update_service_template,
|
||||
fake_uuid,
|
||||
template_type,
|
||||
expected_error,
|
||||
):
|
||||
service_one['permissions'] += [template_type]
|
||||
return mocker.patch(
|
||||
'app.service_api_client.get_service_template',
|
||||
return_value=template_json(
|
||||
SERVICE_ONE_ID,
|
||||
fake_uuid,
|
||||
type_=template_type,
|
||||
),
|
||||
)
|
||||
page = client_request.post(
|
||||
'.edit_service_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
@@ -2047,7 +2068,7 @@ def test_should_not_update_sms_template_with_emoji(
|
||||
},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert "You cannot use 🍔 in text messages." in page.text
|
||||
assert expected_error in page.text
|
||||
assert mock_update_service_template.called is False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user