Warn when the ingest folder has no library to match

Without CWA_URL and CALIBRE_DB_PATH, each update goes to CWA as a new book.
This commit is contained in:
tim
2026-10-02 21:04:49 +02:00
parent c188795852
commit f961e4781e
2 changed files with 20 additions and 0 deletions
+15
View File
@@ -140,3 +140,18 @@ def test_prepare_without_cwa_creates_only_bindery_folders(monkeypatch, tmp_path,
assert config.PERSONAL_INI.exists()
assert {p.name for p in tmp_path.iterdir()} == {"config", "uploads", "tmp"}
assert caplog.records == []
@pytest.mark.parametrize(
("url", "database", "warns"),
[("", None, True), ("https://cwa.invalid", None, False), ("", Path("/library/metadata.db"), False)],
)
def test_prepare_warns_about_an_ingest_folder_without_a_library(monkeypatch, tmp_path, caplog, url, database, warns):
monkeypatch.setattr(config, "CWA_URL", url)
monkeypatch.setattr(config, "CALIBRE_DB_PATH", database)
for name, folder in [("CONFIG_DIR", "config"), ("UPLOAD_DIR", "uploads"), ("TMP_DIR", "tmp"), ("INGEST_DIR", "in")]:
monkeypatch.setattr(config, name, tmp_path / folder)
monkeypatch.setattr(config, "PERSONAL_INI", tmp_path / "config" / "personal.ini")
with caplog.at_level("WARNING"):
config.prepare()
assert ("each update adds a new book" in caplog.text) is warns