Skip to content

Commit

Permalink
(Autocomplétion) Ajout d'un test
Browse files Browse the repository at this point in the history
  • Loading branch information
Situphen committed Sep 21, 2024
1 parent 12d1ab4 commit 08f174b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions zds/member/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ def test_search_without_results_in_list_of_users(self):
self.assertIsNone(response.data.get("next"))
self.assertIsNone(response.data.get("previous"))

def test_search_with_results_in_right_order(self):
"""
Gets list of users corresponding to part of a username and
verifies that the list of usernames returned is in the right order.
"""
for username in ("Andr0", "pierre", "alexandre", "misterandrew", "andré", "jacques", "Andromède", "Android"):
ProfileFactory(user__username=username)

response = self.client.get(reverse("api:member:list") + "?search=Andr")
list_of_usernames = [item.get("username") for item in response.data.get("results")]
self.assertEqual(list_of_usernames, ["Andr0", "Android", "Andromède", "andré", "alexandre", "misterandrew"])

def test_register_new_user(self):
"""
Registers a new user in the database.
Expand Down

0 comments on commit 08f174b

Please sign in to comment.