-
Notifications
You must be signed in to change notification settings - Fork 80
/
test_settings_distinct_attribute_meilisearch.py
51 lines (43 loc) · 1.99 KB
/
test_settings_distinct_attribute_meilisearch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
NEW_DISTINCT_ATTRIBUTE = "title"
DEFAULT_DISTINCT_ATTRIBUTE = None
def test_get_distinct_attribute(empty_index):
"""Tests geting the distinct attribute."""
response = empty_index().get_distinct_attribute()
assert response == DEFAULT_DISTINCT_ATTRIBUTE
def test_update_distinct_attribute(empty_index):
"""Tests updating a custom distinct attribute."""
index = empty_index()
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
index.wait_for_task(response.task_uid)
response = index.get_distinct_attribute()
assert response == NEW_DISTINCT_ATTRIBUTE
def test_update_distinct_at_to_none(empty_index):
"""Tests updating distinct attribute at null."""
index = empty_index()
# Update the settings first
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
update = index.wait_for_task(response.task_uid)
assert update.status == "succeeded"
# Check the settings have been correctly updated
response = index.get_distinct_attribute()
assert response == NEW_DISTINCT_ATTRIBUTE
# Launch test to update at null the setting
response = index.update_distinct_attribute(None)
index.wait_for_task(response.task_uid)
response = index.get_distinct_attribute()
assert response == DEFAULT_DISTINCT_ATTRIBUTE
def test_reset_distinct_attribute(empty_index):
"""Tests resetting the distinct attribute setting to its default value."""
index = empty_index()
# Update the settings first
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
update = index.wait_for_task(response.task_uid)
assert update.status == "succeeded"
# Check the settings have been correctly updated
response = index.get_distinct_attribute()
assert response == NEW_DISTINCT_ATTRIBUTE
# Check the reset of the settings
response = index.reset_distinct_attribute()
index.wait_for_task(response.task_uid)
response = index.get_distinct_attribute()
assert response == DEFAULT_DISTINCT_ATTRIBUTE