Compare commits

...

1 Commits

Author SHA1 Message Date
Richie 6d2c001735 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
2026-06-14 02:39:38 -04:00
2 changed files with 13 additions and 4 deletions
+7 -1
View File
@@ -13,6 +13,7 @@ from sqlalchemy import literal, select
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from python.ebook_search.bm25_corpus import ( from python.ebook_search.bm25_corpus import (
BM25CorpusUnavailableError,
load_bm25_corpus, load_bm25_corpus,
score_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]: def bm25_candidates(query: str, config: EbookSearchConfig) -> list[SearchResult]:
"""Return BM25-ranked lexical candidates using the persisted corpus.""" """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: if not corpus.records:
logger.info("ebook_bm25_search_complete corpus=0 candidates=0") logger.info("ebook_bm25_search_complete corpus=0 candidates=0")
return [] return []
+6 -3
View File
@@ -21,7 +21,7 @@ def test_validate_system(mocker: MockerFixture, fs: FakeFilesystem) -> None:
"""test_validate_system.""" """test_validate_system."""
fs.create_file( fs.create_file(
"/mock_snapshot_config.toml", "/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) 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.""" """test_validate_system_errors."""
fs.create_file( fs.create_file(
"/mock_snapshot_config.toml", "/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}.systemd_tests", return_value=["systemd_tests error"])
mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", return_value=["zpool_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.""" """test_validate_system_execution."""
fs.create_file( fs.create_file(
"/mock_snapshot_config.toml", "/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")) mocker.patch(f"{VALIDATE_SYSTEM}.zpool_tests", side_effect=RuntimeError("zpool_tests error"))
with pytest.raises(SystemExit) as exception_info: with pytest.raises(SystemExit) as exception_info: