Wait only 5 seconds for CWA on the story page
A job still waits for the full timeout.
This commit is contained in:
@@ -99,6 +99,7 @@ def test_library_search_link_import_and_unlink(client, story, monkeypatch):
|
||||
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"
|
||||
cwa.get_book.assert_called_with("book-7", timeout=5) # the page does not wait long for CWA
|
||||
cwa.get_book.side_effect = None
|
||||
cwa.get_book.return_value = None
|
||||
assert client.post(f"/api/stories/{sid}/link", json={"uuid": "missing"}, headers=H).status_code == 404
|
||||
|
||||
@@ -75,6 +75,17 @@ def test_get_book(fake):
|
||||
assert c.get_book("nope") is None
|
||||
|
||||
|
||||
def test_get_book_can_wait_for_a_shorter_time(fake, monkeypatch):
|
||||
c = client(fake)
|
||||
get = c.session.get
|
||||
timeouts = []
|
||||
monkeypatch.setattr(c.session, "get", lambda url, **kw: timeouts.append(kw["timeout"]) or get(url, **kw))
|
||||
c.get_book("uuid-2", timeout=5)
|
||||
c.get_book("uuid-2")
|
||||
c.search("Story")
|
||||
assert timeouts == [5, 60, 60]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("book_uuid", ["../opds", "uuid-2?x=1", "uuid-2#x", "uuid%2F2", ""])
|
||||
def test_get_book_refuses_a_uuid_that_changes_the_path(book_uuid):
|
||||
# Nothing listens on this port, so a request would raise CwaError.
|
||||
|
||||
Reference in New Issue
Block a user