fixed test
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 28s
build_systems / build-brain (pull_request) Successful in 49s
build_systems / build-bob (pull_request) Successful in 50s
build_systems / build-leviathan (pull_request) Successful in 53s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m1s
build_systems / build-jeeves (pull_request) Successful in 2m39s
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 28s
build_systems / build-brain (pull_request) Successful in 49s
build_systems / build-bob (pull_request) Successful in 50s
build_systems / build-leviathan (pull_request) Successful in 53s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m1s
build_systems / build-jeeves (pull_request) Successful in 2m39s
This commit is contained in:
@@ -13,6 +13,7 @@ from sqlalchemy import literal, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from python.ebook_search.bm25_corpus import (
|
||||
BM25CorpusUnavailableError,
|
||||
load_bm25_corpus,
|
||||
score_bm25_corpus,
|
||||
)
|
||||
@@ -252,7 +253,12 @@ def vector_candidates(engine: Engine, query: str, config: EbookSearchConfig) ->
|
||||
|
||||
def bm25_candidates(query: str, config: EbookSearchConfig) -> list[SearchResult]:
|
||||
"""Return BM25-ranked lexical candidates using the persisted corpus."""
|
||||
corpus = load_bm25_corpus(config)
|
||||
try:
|
||||
corpus = load_bm25_corpus(config)
|
||||
except BM25CorpusUnavailableError as error:
|
||||
logger.warning("ebook_bm25_index_unavailable_skipping error=%s", error)
|
||||
return []
|
||||
|
||||
if not corpus.records:
|
||||
logger.info("ebook_bm25_search_complete corpus=0 candidates=0")
|
||||
return []
|
||||
|
||||
@@ -21,7 +21,7 @@ def test_validate_system(mocker: MockerFixture, fs: FakeFilesystem) -> None:
|
||||
"""test_validate_system."""
|
||||
fs.create_file(
|
||||
"/mock_snapshot_config.toml",
|
||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
)
|
||||
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=None)
|
||||
@@ -33,9 +33,10 @@ def test_validate_system_errors(mocker: MockerFixture, fs: FakeFilesystem) -> No
|
||||
"""test_validate_system_errors."""
|
||||
fs.create_file(
|
||||
"/mock_snapshot_config.toml",
|
||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
)
|
||||
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.signal_alert")
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=["systemd_tests error"])
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", return_value=["zpool_tests error"])
|
||||
|
||||
@@ -49,9 +50,11 @@ def test_validate_system_execution(mocker: MockerFixture, fs: FakeFilesystem) ->
|
||||
"""test_validate_system_execution."""
|
||||
fs.create_file(
|
||||
"/mock_snapshot_config.toml",
|
||||
contents='zpool = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
contents='zpools = ["root_pool", "storage", "media"]\nservices = ["docker"]\n',
|
||||
)
|
||||
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.signal_alert")
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.systemd_tests", return_value=None)
|
||||
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", side_effect=RuntimeError("zpool_tests error"))
|
||||
|
||||
with pytest.raises(SystemExit) as exception_info:
|
||||
|
||||
Reference in New Issue
Block a user