From a85dc26d9149d8e011a0da8d546dc4c4d431a2b1 Mon Sep 17 00:00:00 2001 From: "Alexis A." Date: Wed, 2 Oct 2024 16:53:14 +0200 Subject: [PATCH 1/4] fix(is_alpha_validator): allow apostrophe --- utils/validators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/validators.py b/utils/validators.py index 9e51b407f..657a32996 100644 --- a/utils/validators.py +++ b/utils/validators.py @@ -2,7 +2,8 @@ def is_alpha_valid(value: str) -> bool: - return all(char.isalpha() or char == " " or char == "-" for char in value) + special_chars_allowed = [" ", "-", "'"] + return all(char.isalpha() or char in special_chars_allowed for char in value) def is_alpha_validator(value: str) -> bool: From ca23a09a3dd09b4195c3d548b150d66da3fafe48 Mon Sep 17 00:00:00 2001 From: "Alexis A." Date: Wed, 2 Oct 2024 17:02:44 +0200 Subject: [PATCH 2/4] test(signup): check special chars are accepted --- users/tests/SignupTest.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/users/tests/SignupTest.py b/users/tests/SignupTest.py index 6bada2480..f561a39db 100644 --- a/users/tests/SignupTest.py +++ b/users/tests/SignupTest.py @@ -62,3 +62,20 @@ def test_signup_form_with_different_passwords(self) -> None: field="password2", errors="Les mots de passe ne sont pas identiques", ) + + def test_allowed_characters_are_accepted(self) -> None: + fields_to_test = { + "first_name": "John-Doe", + "last_name": "John Do'e", + "function": "Test", + } + + data = {**valid_payload, **fields_to_test} + + response = self.client.post(path=form_url, data=data) + self.assertFormError( + response=response, + form="form", + field=None, + errors=[], + ) From 66e9c89126e3fc8058ab528a52254a771415c2c1 Mon Sep 17 00:00:00 2001 From: "Alexis A." Date: Wed, 2 Oct 2024 17:24:24 +0200 Subject: [PATCH 3/4] test(signup): check that accents are accepted --- users/tests/SignupTest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/users/tests/SignupTest.py b/users/tests/SignupTest.py index f561a39db..3ffb507e9 100644 --- a/users/tests/SignupTest.py +++ b/users/tests/SignupTest.py @@ -79,3 +79,13 @@ def test_allowed_characters_are_accepted(self) -> None: field=None, errors=[], ) + + def test_accents_are_accepted(self): + data = {**valid_payload, **{"first_name": "Jérôme"}} + response = self.client.post(path=form_url, data=data) + self.assertFormError( + response=response, + form="form", + field=None, + errors=[], + ) From 637e9d1ad232533d5bda1f0f432dec24884e4de9 Mon Sep 17 00:00:00 2001 From: "Alexis A." Date: Wed, 2 Oct 2024 17:37:44 +0200 Subject: [PATCH 4/4] test(test_signup): rename file --- users/tests/{SignupTest.py => test_signup.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename users/tests/{SignupTest.py => test_signup.py} (100%) diff --git a/users/tests/SignupTest.py b/users/tests/test_signup.py similarity index 100% rename from users/tests/SignupTest.py rename to users/tests/test_signup.py