Filter the import search from the list of library books
The search through CWA gave no results for books that the full list shows. The search now filters the list that "Show all stories in the library" loads, by title, author and site. The buttons stay disabled until the answer comes. A book that the user imports leaves the list.
This commit is contained in:
@@ -92,24 +92,11 @@ def test_library_search_link_import_and_unlink(client, story, monkeypatch):
|
||||
monkeypatch.setattr(o, "cwa", lambda: cwa)
|
||||
monkeypatch.setattr(config, "CWA_URL", "https://cwa.example")
|
||||
assert client.get("/api/library/candidates").json[0]["id"] == 7
|
||||
cwa.search.assert_not_called()
|
||||
# A search for candidates shows only the story-site books that have an ePub.
|
||||
cwa.search.return_value = [
|
||||
book,
|
||||
Book(8, "book-8", "Title in PDF", ["Writer"], "www.royalroad.com", {"pdf": "/book.pdf"}),
|
||||
Book(9, "book-9", "Title of a novel", ["Writer"], "A Publisher", {"epub": "/novel.epub"}),
|
||||
]
|
||||
assert [b["id"] for b in client.get("/api/library/candidates?q=Title").json] == [7]
|
||||
cwa.search.assert_called_once_with("Title")
|
||||
assert cwa.site_books.call_count == 1
|
||||
cwa.search.reset_mock()
|
||||
cwa.search.return_value = [book]
|
||||
assert client.get("/api/library/search?q=Title").json[0]["tracked_as"] is None
|
||||
cwa.search.assert_called_once_with("Title")
|
||||
linked = client.post(f"/api/stories/{sid}/link", json={"uuid": "book-7"}, headers=H)
|
||||
assert linked.json["calibre_id"] == 7
|
||||
assert client.get("/api/library/candidates").json == []
|
||||
assert client.get("/api/library/candidates?q=Title").json == []
|
||||
assert client.get("/api/library/search?q=Title").json[0]["tracked_as"] == "Story"
|
||||
cwa.get_book.side_effect = CwaError("offline")
|
||||
assert client.get(f"/api/stories/{sid}").json["library_error"] == "offline"
|
||||
|
||||
Reference in New Issue
Block a user