#48 Tests finished

* finishes user autocomplete unit test
This commit is contained in:
mpeltriaux 2021-12-15 09:34:40 +01:00
parent 6b81e3efd8
commit 6b018e5495
2 changed files with 26 additions and 2 deletions

View File

@ -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 = "QuziFeih7U8DZvQQ1riPv2MXz0ZABupHED9wjoqZAqeMQaqkqTfxJDRXgSIyASwJ"
SSO_PUBLIC_KEY = "AGGK7E8eT5X5u2GD38ygGG3GpAefmIldJiiWW7gldRPqCG1CzmUfGdvPSGDbEY2n"
# MAPS
DEFAULT_LAT = 50.00

View File

@ -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"])