From 08f174bd98c3ef4ee3663506c28c6a898270c0bd Mon Sep 17 00:00:00 2001 From: Situphen Date: Sat, 21 Sep 2024 21:58:53 +0200 Subject: [PATCH] =?UTF-8?q?(Autocompl=C3=A9tion)=20Ajout=20d'un=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zds/member/api/tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zds/member/api/tests.py b/zds/member/api/tests.py index e86f100626..5c6b926831 100644 --- a/zds/member/api/tests.py +++ b/zds/member/api/tests.py @@ -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.