Search the library in the import section

The search shows the matches from a story site that Bindery does not track yet. The button that lists every such book stays.
This commit is contained in:
tim
2026-10-04 02:04:16 +02:00
parent d28f69d93a
commit b73b2808ca
6 changed files with 117 additions and 15 deletions
+10 -1
View File
@@ -151,9 +151,18 @@ def test_library_candidates_and_search(fake):
"formats": ["epub"],
}
]
# A search shows only the matches from a story site.
fake.books.append(FakeBook(2, "uuid-2", "Test Novel", publisher="A Publisher", epub=b"x"))
fake.books.append(FakeBook(4, "uuid-4", "Other Story", publisher="www.royalroad.com", epub=b"x"))
assert [b["id"] for b in orchestrator.search_library("test")] == [1, 2]
assert orchestrator.library_candidates("test") == candidates
assert [b["id"] for b in orchestrator.library_candidates("story")] == [1, 4]
assert orchestrator.library_candidates("nothing") == []
assert orchestrator.library_candidates(" ") == []
story_id = add_story()
orchestrator.link_story(story_id, "uuid-1")
assert orchestrator.library_candidates() == []
assert [b["id"] for b in orchestrator.library_candidates()] == [4]
assert orchestrator.library_candidates("test") == []
assert orchestrator.search_library("test")[0]["tracked_as"] == "Test Story"
with pytest.raises(KeyError):
orchestrator.link_story(story_id, "uuid-nope")