allow downgradeable unicode characters in SMS templates

This commit is contained in:
Leo Hemsted
2017-02-14 17:06:32 +00:00
parent c25fff9032
commit 73a965a3c6
2 changed files with 24 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import pytest
from app.main.forms import RegisterUserForm, ServiceSmsSender
from app.main.validators import ValidGovEmail, NoCommasInPlaceHolders
from app.main.validators import ValidGovEmail, NoCommasInPlaceHolders, OnlyGSMCharacters
from wtforms import ValidationError
from unittest.mock import Mock
@@ -141,6 +141,21 @@ def test_for_commas_in_placeholders(
NoCommasInPlaceHolders()(None, _gen_mock_field('Hello ((name))'))
@pytest.mark.parametrize('msg', ['The quick brown fox', 'Thé “quick” bröwn fox\u200B'])
def test_gsm_character_validation(client, msg):
OnlyGSMCharacters()(None, _gen_mock_field(msg))
def test_non_gsm_character_validation(client):
with pytest.raises(ValidationError) as error:
OnlyGSMCharacters()(None, _gen_mock_field('∆ abc 📲 def 📵 ghi'))
assert str(error.value) == (
'You cant use ‘∆’, ‘📲’ or ‘📵’ in text messages. '
'They wont show up properly on everyones phones.'
)
def test_sms_sender_form_validation(
client,
mock_get_user_by_email,