Skip to content

Commit 7e6f9fb

Browse files
authored
Update tests about the settings reset (#182)
1 parent 1f8b917 commit 7e6f9fb

7 files changed

+75
-4
lines changed

meilisearch/tests/settings/test_settings_attributes_for_faceting_meilisearch.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pylint: disable=invalid-name
22

3+
ATTRIBUTES_FOR_FACETING = ['title', 'release_date']
4+
35
def test_get_attributes_for_faceting(empty_index):
46
""" Tests getting the attributes for faceting """
57
response = empty_index().get_attributes_for_faceting()
@@ -8,19 +10,29 @@ def test_get_attributes_for_faceting(empty_index):
810

911
def test_update_attributes_for_faceting(empty_index):
1012
"""Tests updating the attributes for faceting"""
11-
attributes_for_faceting = ['title', 'release_date']
1213
index = empty_index()
13-
response = index.update_attributes_for_faceting(attributes_for_faceting)
14+
response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING)
1415
index.wait_for_pending_update(response['updateId'])
1516
get_attributes_new = index.get_attributes_for_faceting()
16-
assert len(get_attributes_new) == len(attributes_for_faceting)
17+
assert len(get_attributes_new) == len(ATTRIBUTES_FOR_FACETING)
1718
get_attributes = index.get_attributes_for_faceting()
18-
for attribute in attributes_for_faceting:
19+
for attribute in ATTRIBUTES_FOR_FACETING:
1920
assert attribute in get_attributes
2021

2122
def test_reset_attributes_for_faceting(empty_index):
2223
"""Tests the reset of attributes for faceting to default values (in dataset)"""
2324
index = empty_index()
25+
# Update the settings first
26+
response = index.update_attributes_for_faceting(ATTRIBUTES_FOR_FACETING)
27+
update = index.wait_for_pending_update(response['updateId'])
28+
assert update['status'] == 'processed'
29+
# Check the settings have been correctly updated
30+
get_attributes_new = index.get_attributes_for_faceting()
31+
assert len(get_attributes_new) == len(ATTRIBUTES_FOR_FACETING)
32+
get_attributes = index.get_attributes_for_faceting()
33+
for attribute in ATTRIBUTES_FOR_FACETING:
34+
assert attribute in get_attributes
35+
# Check the reset of the settings
2436
response = index.reset_attributes_for_faceting()
2537
assert isinstance(response, object)
2638
assert 'updateId' in response

meilisearch/tests/settings/test_settings_displayed_attributes_meilisearch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ def test_update_displayed_attributes(empty_index):
2727
def test_reset_displayed_attributes(empty_index):
2828
"""Tests the reset of displayedAttributes to default values (in dataset)"""
2929
index = empty_index()
30+
# Update the settings first
31+
response = index.update_displayed_attributes(DISPLAYED_ATTRIBUTES)
32+
update = index.wait_for_pending_update(response['updateId'])
33+
assert update['status'] == 'processed'
34+
# Check the settings have been correctly updated
35+
get_attributes_new = index.get_displayed_attributes()
36+
assert len(get_attributes_new) == len(DISPLAYED_ATTRIBUTES)
37+
for attribute in DISPLAYED_ATTRIBUTES:
38+
assert attribute in get_attributes_new
39+
# Check the reset of the settings
3040
response = index.reset_displayed_attributes()
3141
assert isinstance(response, object)
3242
assert 'updateId' in response

meilisearch/tests/settings/test_settings_distinct_attribute_meilisearch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ def test_update_distinct_attribute(empty_index):
2323
def test_reset_distinct_attribute(empty_index):
2424
"""Tests resetting distinct attribute"""
2525
index = empty_index()
26+
# Update the settings first
27+
response = index.update_distinct_attribute(NEW_DISTINCT_ATTRIBUTE)
28+
update = index.wait_for_pending_update(response['updateId'])
29+
assert update['status'] == 'processed'
30+
# Check the settings have been correctly updated
31+
response = index.get_distinct_attribute()
32+
assert isinstance(response, object)
33+
assert response == NEW_DISTINCT_ATTRIBUTE
34+
# Check the reset of the settings
2635
response = index.reset_distinct_attribute()
2736
assert isinstance(response, object)
2837
assert 'updateId' in response

meilisearch/tests/settings/test_settings_ranking_rules_meilisearch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ def test_update_ranking_rules(empty_index):
3131
def test_reset_ranking_rules(empty_index):
3232
"""Tests resetting the ranking rules"""
3333
index = empty_index()
34+
# Update the settings first
35+
response = index.update_ranking_rules(NEW_RANKING_RULES)
36+
update = index.wait_for_pending_update(response['updateId'])
37+
assert update['status'] == 'processed'
38+
# Check the settings have been correctly updated
39+
response = index.get_ranking_rules()
40+
assert isinstance(response, object)
41+
for rule in NEW_RANKING_RULES:
42+
assert rule in response
43+
# Check the reset of the settings
3444
response = index.reset_ranking_rules()
3545
assert isinstance(response, object)
3646
assert 'updateId' in response

meilisearch/tests/settings/test_settings_searchable_attributes_meilisearch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ def test_update_searchable_attributes(empty_index):
2929
def test_reset_searchable_attributes(empty_index):
3030
"""Tests reseting searchable attributes"""
3131
index = empty_index()
32+
# Update the settings first
33+
response = index.update_searchable_attributes(NEW_SEARCHABLE_ATTRIBUTES)
34+
update = index.wait_for_pending_update(response['updateId'])
35+
assert update['status'] == 'processed'
36+
# Check the settings have been correctly updated
37+
response = index.get_searchable_attributes()
38+
assert len(response) == len(NEW_SEARCHABLE_ATTRIBUTES)
39+
for attribute in NEW_SEARCHABLE_ATTRIBUTES:
40+
assert attribute in response
41+
# Check the reset of the settings
3242
response = index.reset_searchable_attributes()
3343
assert isinstance(response, object)
3444
assert 'updateId' in response

meilisearch/tests/settings/test_settings_stop_words_meilisearch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ def test_update_stop_words(empty_index):
2323
def test_reset_stop_words(empty_index):
2424
"""Tests call to reset stop words"""
2525
index = empty_index()
26+
# Update the settings first
27+
response = index.update_stop_words(NEW_STOP_WORDS)
28+
update = index.wait_for_pending_update(response['updateId'])
29+
assert update['status'] == 'processed'
30+
# Check the settings have been correctly updated
31+
response = index.get_stop_words()
32+
assert isinstance(response, object)
33+
for stop_word in NEW_STOP_WORDS:
34+
assert stop_word in response
35+
# Check the reset of the settings
2636
response = index.reset_stop_words()
2737
assert isinstance(response, object)
2838
assert 'updateId' in response

meilisearch/tests/settings/test_settings_synonyms_meilisearch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ def test_update_synonyms(empty_index):
2525
def test_reset_synonyms(empty_index):
2626
"""Tests resetting synonyms"""
2727
index = empty_index()
28+
# Update the settings first
29+
response = index.update_synonyms(NEW_SYNONYMS)
30+
update = index.wait_for_pending_update(response['updateId'])
31+
assert update['status'] == 'processed'
32+
# Check the settings have been correctly updated
33+
response = index.get_synonyms()
34+
assert isinstance(response, object)
35+
for synonym in NEW_SYNONYMS:
36+
assert synonym in response
37+
# Check the reset of the settings
2838
response = index.reset_synonyms()
2939
assert isinstance(response, object)
3040
assert 'updateId' in response

0 commit comments

Comments
 (0)