mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-24 12:21:22 -05:00
fix non-gsm error message
Use `it`/`they` depending on how many different characters you've used Also don't wrap the message with quotes, as it looks confusing and potentialy implies that you can't use apostrophes
This commit is contained in:
@@ -58,7 +58,8 @@ class OnlyGSMCharacters:
|
||||
non_gsm_characters = sorted(list(get_non_gsm_compatible_characters(field.data)))
|
||||
if non_gsm_characters:
|
||||
raise ValidationError(
|
||||
'You can’t use {} in text messages. They won’t show up properly on everyone’s phones.'.format(
|
||||
formatted_list(non_gsm_characters, conjunction='or')
|
||||
'You can’t use {} in text messages. {} won’t show up properly on everyone’s phones.'.format(
|
||||
formatted_list(non_gsm_characters, conjunction='or', before_each='', after_each=''),
|
||||
('It' if len(non_gsm_characters) == 1 else 'They')
|
||||
)
|
||||
)
|
||||
|
||||
@@ -146,14 +146,27 @@ def test_gsm_character_validation(client, msg):
|
||||
OnlyGSMCharacters()(None, _gen_mock_field(msg))
|
||||
|
||||
|
||||
def test_non_gsm_character_validation(client):
|
||||
@pytest.mark.parametrize('data, err_msg', [
|
||||
(
|
||||
'∆ abc 📲 def 📵 ghi',
|
||||
(
|
||||
'You can’t use ∆, 📲 or 📵 in text messages. '
|
||||
'They won’t show up properly on everyone’s phones.'
|
||||
)
|
||||
),
|
||||
(
|
||||
'📵',
|
||||
(
|
||||
'You can’t use 📵 in text messages. '
|
||||
'It won’t show up properly on everyone’s phones.'
|
||||
)
|
||||
),
|
||||
])
|
||||
def test_non_gsm_character_validation(data, err_msg, client):
|
||||
with pytest.raises(ValidationError) as error:
|
||||
OnlyGSMCharacters()(None, _gen_mock_field('∆ abc 📲 def 📵 ghi'))
|
||||
OnlyGSMCharacters()(None, _gen_mock_field(data))
|
||||
|
||||
assert str(error.value) == (
|
||||
'You can’t use ‘∆’, ‘📲’ or ‘📵’ in text messages. '
|
||||
'They won’t show up properly on everyone’s phones.'
|
||||
)
|
||||
assert str(error.value) == err_msg
|
||||
|
||||
|
||||
def test_sms_sender_form_validation(
|
||||
|
||||
@@ -670,7 +670,7 @@ def test_should_not_create_sms_template_with_emoji(
|
||||
), data=data)
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert "You can’t use ‘🍜’ in text messages." in resp.get_data(as_text=True)
|
||||
assert "You can’t use 🍜 in text messages." in resp.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_not_update_sms_template_with_emoji(
|
||||
@@ -694,7 +694,7 @@ def test_should_not_update_sms_template_with_emoji(
|
||||
template_id=fake_uuid), data=data)
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert "You can’t use ‘🍔’ in text messages." in resp.get_data(as_text=True)
|
||||
assert "You can’t use 🍔 in text messages." in resp.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_create_sms_template_without_downgrading_unicode_characters(
|
||||
|
||||
Reference in New Issue
Block a user