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 df1c558 commit db91a0c
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 ("pierre", "andr", "Radon", "alexandre", "MisterAndrew", "andré", "dragon", "Andromède"):
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, ["andr", "Andromède", "andré", "MisterAndrew", "alexandre"])

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

0 comments on commit db91a0c

Please sign in to comment.