From d5800802329a1d10cb398d01525b42148e9e6382 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 15 Dec 2021 09:34:40 +0100 Subject: [PATCH] #48 Tests finished * finishes user autocomplete unit test --- konova/settings.py | 4 ++-- konova/tests/test_autocompletes.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/konova/settings.py b/konova/settings.py index b6306e45..1355fbae 100644 --- a/konova/settings.py +++ b/konova/settings.py @@ -51,8 +51,8 @@ PAGE_DEFAULT = 1 # SSO settings SSO_SERVER_BASE = "http://127.0.0.1:8000/" SSO_SERVER = f"{SSO_SERVER_BASE}sso/" -SSO_PRIVATE_KEY = "U7OjCbElNDchUvh9WVzfOfC4juJQC9HGZI9tSdjmeFe0MDTw7BCNBv4MigJ79dlJ" -SSO_PUBLIC_KEY = "PnxIZFewXVoL0FG2wMr3DCGgLCHOwR6JE9GYJCZHazVjlDgOZFl3qiB4dWsAZRF5" +SSO_PRIVATE_KEY = "CHANGE_ME" +SSO_PUBLIC_KEY = "CHANGE_ME" # MAPS DEFAULT_LAT = 50.00 diff --git a/konova/tests/test_autocompletes.py b/konova/tests/test_autocompletes.py index 06dffaab..47df3dc3 100644 --- a/konova/tests/test_autocompletes.py +++ b/konova/tests/test_autocompletes.py @@ -23,6 +23,8 @@ class AutocompleteTestCase(BaseTestCase): self.client.login(username=self.superuser.username, password=self.superuser_pw) user_autocomplete_url = reverse("share-user-autocomplete") username = self.user.username + + # Provide the full name --> success data = { "q": username } @@ -33,3 +35,25 @@ class AutocompleteTestCase(BaseTestCase): content = json.loads(response.content) self.assertEqual(username, content["results"][0]["text"]) self.assertEqual(str(self.user.id), content["results"][0]["id"]) + + # Provide only the first letter --> no result + data = { + "q": username[0] + } + response = self.client.get( + user_autocomplete_url, + data, + ) + content = json.loads(response.content) + self.assertEqual([], content["results"]) + + # Provide full name + too much --> no result + data = { + "q": username + "t" + } + response = self.client.get( + user_autocomplete_url, + data, + ) + content = json.loads(response.content) + self.assertEqual([], content["results"])