Skip to content

Commit 8ea6f72

Browse files
committed
✅(backend) add tests with various case
The user search needs to work wether the name is typed with correct case or not.
1 parent 7e5e69b commit 8ea6f72

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

src/backend/core/tests/test_api_users.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,17 @@ def test_api_users_list_query_email_with_internationalized_domain_names():
8989
jean = factories.UserFactory(email="jean.martin@éducation.fr")
9090
kurokawa = factories.UserFactory(email="contact@黒川.日本")
9191

92-
response = client.get(
93-
"/api/v1.0/users/[email protected]",
94-
)
92+
response = client.get("/api/v1.0/users/[email protected]")
9593
assert response.status_code == 200
9694
user_ids = [user["id"] for user in response.json()]
9795
assert user_ids == [str(jean.id)]
9896

99-
response = client.get(
100-
"/api/v1.0/users/?q=jean.martin@éducation.fr",
101-
)
97+
response = client.get("/api/v1.0/users/?q=jean.martin@éducation.fr")
10298
assert response.status_code == 200
10399
user_ids = [user["id"] for user in response.json()]
104100
assert user_ids == [str(jean.id)]
105101

106-
response = client.get(
107-
"/api/v1.0/users/?q=contact@黒川.日本",
108-
)
102+
response = client.get("/api/v1.0/users/?q=contact@黒川.日本")
109103
assert response.status_code == 200
110104
user_ids = [user["id"] for user in response.json()]
111105
assert user_ids == [str(kurokawa.id)]
@@ -130,16 +124,27 @@ def test_api_users_list_query_full_name():
130124
user_ids = [user["id"] for user in response.json()]
131125
assert user_ids == [str(dave.id)]
132126

133-
response = client.get(
134-
"/api/v1.0/users/?q=Bowman",
135-
)
127+
response = client.get("/api/v1.0/users/?q=Bowman")
136128
assert response.status_code == 200
137129
user_ids = [user["id"] for user in response.json()]
138130
assert user_ids == [str(dave.id)]
139131

140-
response = client.get(
141-
"/api/v1.0/users/?q=Bovin",
142-
)
132+
response = client.get("/api/v1.0/users/?q=bowman")
133+
assert response.status_code == 200
134+
user_ids = [user["id"] for user in response.json()]
135+
assert user_ids == [str(dave.id)]
136+
137+
response = client.get("/api/v1.0/users/?q=BOWMAN")
138+
assert response.status_code == 200
139+
user_ids = [user["id"] for user in response.json()]
140+
assert user_ids == [str(dave.id)]
141+
142+
response = client.get("/api/v1.0/users/?q=BoWmAn")
143+
assert response.status_code == 200
144+
user_ids = [user["id"] for user in response.json()]
145+
assert user_ids == [str(dave.id)]
146+
147+
response = client.get("/api/v1.0/users/?q=Bovin")
143148
assert response.status_code == 200
144149
user_ids = [user["id"] for user in response.json()]
145150
assert user_ids == []
@@ -159,37 +164,27 @@ def test_api_users_list_query_accented_full_name():
159164
email="[email protected]", full_name="Frédérique Lefèvre"
160165
)
161166

162-
response = client.get(
163-
"/api/v1.0/users/?q=Frédérique",
164-
)
167+
response = client.get("/api/v1.0/users/?q=Frédérique")
165168
assert response.status_code == 200
166169
user_ids = [user["id"] for user in response.json()]
167170
assert user_ids == [str(fred.id)]
168171

169-
response = client.get(
170-
"/api/v1.0/users/?q=Frederique",
171-
)
172+
response = client.get("/api/v1.0/users/?q=Frederique")
172173
assert response.status_code == 200
173174
user_ids = [user["id"] for user in response.json()]
174175
assert user_ids == [str(fred.id)]
175176

176-
response = client.get(
177-
"/api/v1.0/users/?q=Lefèvre",
178-
)
177+
response = client.get("/api/v1.0/users/?q=Lefèvre")
179178
assert response.status_code == 200
180179
user_ids = [user["id"] for user in response.json()]
181180
assert user_ids == [str(fred.id)]
182181

183-
response = client.get(
184-
"/api/v1.0/users/?q=Lefevre",
185-
)
182+
response = client.get("/api/v1.0/users/?q=Lefevre")
186183
assert response.status_code == 200
187184
user_ids = [user["id"] for user in response.json()]
188185
assert user_ids == [str(fred.id)]
189186

190-
response = client.get(
191-
"/api/v1.0/users/?q=François Lorfebvre",
192-
)
187+
response = client.get("/api/v1.0/users/?q=François Lorfebvre")
193188
assert response.status_code == 200
194189
users = [user["full_name"] for user in response.json()]
195190
assert users == []

0 commit comments

Comments
 (0)