Files
odysseus/tests/cli/test_docs_cli_content_length.py
T
Merajul Arefin f00ae350cd fix(cli): multi-word and literal-wildcard search in odysseus-docs (#7007)
* fix(cli): multi-word and literal-wildcard search in odysseus-docs

odysseus-docs search wrapped the whole query in one `%{query}%` LIKE over title/current_content, so multi-word queries only matched the exact adjacent phrase and literal % / _ acted as SQL wildcards. Split on whitespace, AND per token, and escape LIKE wildcards with the shared escape_like_pattern() helper. Whitespace-only queries now match all documents, consistent with document-library search.

Fixes #2123.

Tests: tests/cli/test_docs_cli_search.py (5 tests; multi-word, %, _, backslash, whitespace); 4 fail pre-fix, 5 pass post-fix. tests/cli full suite: 82 passed.

* test(cli): name whitespace-query search test accurately

The test passes a whitespace-only query, not an empty one; the old name implied a different input. Behavior is unchanged.
2026-11-02 23:48:14 +00:00

12 lines
424 B
Python

from tests.helpers.cli_loader import load_script
from tests.helpers.db_stubs import make_core_db_stub
def test_text_len_ignores_non_string_values(monkeypatch):
make_core_db_stub(monkeypatch, models=["Document", "DocumentVersion", "ChatMessage", "Session"])
cli = load_script("odysseus-docs")
assert cli._text_len("hello") == 5
assert cli._text_len(None) == 0
assert cli._text_len({"bad": "row"}) == 0