-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
871: Support text separator customization r=sanders41 a=ellnix # Pull Request ## Related issue Fixes #852 ## PR checklist Please check if your PR fulfills the following requirements: - [X] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [X] Have you read the contributing guidelines? - [X] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: ellnix <103502144+ellnix@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
tests/settings/test_settings_text_separators_meilisearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
NEW_SEPARATOR_TOKENS = ["|", "…"] | ||
NEW_NON_SEPARATOR_TOKENS = ["@", "#"] | ||
|
||
|
||
def test_get_separator_tokens_default(empty_index): | ||
"""Tests getting the default value of separator tokens.""" | ||
separator_tokens = empty_index().get_separator_tokens() | ||
assert separator_tokens == [] | ||
|
||
|
||
def test_get_non_separator_tokens_default(empty_index): | ||
"""Tests getting the default value of separator tokens.""" | ||
non_separator_tokens = empty_index().get_separator_tokens() | ||
assert non_separator_tokens == [] | ||
|
||
|
||
def test_update_separator_tokens(empty_index): | ||
"""Tests updating the separator tokens.""" | ||
index = empty_index() | ||
task = index.update_separator_tokens(NEW_SEPARATOR_TOKENS) | ||
task = index.wait_for_task(task.task_uid) | ||
assert task.status == "succeeded" | ||
|
||
separator_tokens = index.get_separator_tokens() | ||
for token in NEW_SEPARATOR_TOKENS: | ||
assert token in separator_tokens | ||
|
||
|
||
def test_update_non_separator_tokens(empty_index): | ||
"""Tests updating the non separator tokens.""" | ||
index = empty_index() | ||
task = index.update_non_separator_tokens(NEW_NON_SEPARATOR_TOKENS) | ||
task = index.wait_for_task(task.task_uid) | ||
assert task.status == "succeeded" | ||
|
||
non_separator_tokens = index.get_non_separator_tokens() | ||
for token in NEW_NON_SEPARATOR_TOKENS: | ||
assert token in non_separator_tokens | ||
|
||
|
||
def test_reset_separator_tokens(empty_index): | ||
"""Tests resetting the separator tokens to its default empty list.""" | ||
index = empty_index() | ||
task = index.update_separator_tokens(NEW_SEPARATOR_TOKENS) | ||
task = index.wait_for_task(task.task_uid) | ||
assert task.status == "succeeded" | ||
|
||
separator_tokens = index.get_separator_tokens() | ||
for token in NEW_SEPARATOR_TOKENS: | ||
assert token in separator_tokens | ||
|
||
reset_task = index.reset_separator_tokens() | ||
reset_task = index.wait_for_task(reset_task.task_uid) | ||
assert reset_task.status == "succeeded" | ||
|
||
separator_tokens = index.get_separator_tokens() | ||
assert separator_tokens == [] | ||
|
||
|
||
def test_non_reset_separator_tokens(empty_index): | ||
"""Tests resetting the separator tokens to its default empty list.""" | ||
index = empty_index() | ||
task = index.update_non_separator_tokens(NEW_NON_SEPARATOR_TOKENS) | ||
task = index.wait_for_task(task.task_uid) | ||
assert task.status == "succeeded" | ||
|
||
non_separator_tokens = index.get_non_separator_tokens() | ||
for token in NEW_NON_SEPARATOR_TOKENS: | ||
assert token in non_separator_tokens | ||
|
||
reset_task = index.reset_non_separator_tokens() | ||
reset_task = index.wait_for_task(reset_task.task_uid) | ||
assert reset_task.status == "succeeded" | ||
|
||
non_separator_tokens = index.get_non_separator_tokens() | ||
assert non_separator_tokens == [] |