Skip to content

Commit 9d008a7

Browse files
committed
Improve test readability
1 parent cb7f921 commit 9d008a7

File tree

1 file changed

+27
-39
lines changed

1 file changed

+27
-39
lines changed

tests/settings/test_settings_typo_tolerance_meilisearch.py

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,39 @@ def test_get_typo_tolerance_default(empty_index):
2828
def test_update_typo_tolerance(empty_index):
2929
"""Tests updating typo_tolerance."""
3030
index = empty_index()
31+
response_update = index.update_typo_tolerance(NEW_TYPO_TOLERANCE)
32+
update = index.wait_for_task(response_update['uid'])
33+
response_get = index.get_typo_tolerance()
3134

32-
response = index.update_typo_tolerance(NEW_TYPO_TOLERANCE)
33-
34-
assert isinstance(response, dict)
35-
assert 'uid' in response
36-
37-
update = index.wait_for_task(response['uid'])
38-
35+
assert isinstance(response_update, dict)
36+
assert 'uid' in response_update
3937
assert update['status'] == 'succeeded'
40-
41-
response = index.get_typo_tolerance()
42-
43-
assert isinstance(response, dict)
38+
assert isinstance(response_get, dict)
4439
for typo_tolerance in NEW_TYPO_TOLERANCE:
45-
assert typo_tolerance in response
46-
assert NEW_TYPO_TOLERANCE[typo_tolerance] == response[typo_tolerance]
40+
assert typo_tolerance in response_get
41+
assert NEW_TYPO_TOLERANCE[typo_tolerance] == response_get[typo_tolerance]
4742

4843
def test_reset_typo_tolerance(empty_index):
4944
"""Tests resetting the typo_tolerance setting to its default value."""
5045
index = empty_index()
5146

52-
# Update the settings first
53-
response = index.update_typo_tolerance(NEW_TYPO_TOLERANCE)
54-
update = index.wait_for_task(response['uid'])
55-
56-
assert update['status'] == 'succeeded'
57-
58-
# Check the settings have been correctly updated
59-
response = index.get_typo_tolerance()
60-
61-
assert isinstance(response, dict)
47+
# Update the settings
48+
response_update = index.update_typo_tolerance(NEW_TYPO_TOLERANCE)
49+
update1 = index.wait_for_task(response_update['uid'])
50+
# Get the setting after update
51+
response_get = index.get_typo_tolerance()
52+
# Reset the setting
53+
response_reset = index.reset_typo_tolerance()
54+
update2 = index.wait_for_task(response_reset['uid'])
55+
# Get the setting after reset
56+
response_last = index.get_typo_tolerance()
57+
58+
assert update1['status'] == 'succeeded'
59+
assert isinstance(response_get, dict)
6260
for typo_tolerance in NEW_TYPO_TOLERANCE:
63-
assert typo_tolerance in response
64-
assert NEW_TYPO_TOLERANCE[typo_tolerance] == response[typo_tolerance]
65-
66-
# Check the reset of the settings
67-
response = index.reset_typo_tolerance()
68-
69-
assert isinstance(response, dict)
70-
assert 'uid' in response
71-
72-
update = index.wait_for_task(response['uid'])
73-
74-
assert update['status'] == 'succeeded'
75-
76-
response = index.get_typo_tolerance()
77-
78-
assert response == DEFAULT_TYPO_TOLERANCE
61+
assert typo_tolerance in response_get
62+
assert NEW_TYPO_TOLERANCE[typo_tolerance] == response_get[typo_tolerance]
63+
assert isinstance(response_reset, dict)
64+
assert 'uid' in response_reset
65+
assert update2['status'] == 'succeeded'
66+
assert response_last == DEFAULT_TYPO_TOLERANCE

0 commit comments

Comments
 (0)