fix(metadata): pick the right book row per hardcover series position
Build image / image (push) Successful in 1m49s
Build image / image (push) Successful in 1m49s
This commit is contained in:
1 parent
dc83071a0a
commit
13e2a0693e
2 files changed
+83
-3
No files matched your search
@@ -140,6 +140,46 @@ def test_hardcover_series_prefers_the_row_with_an_edition_in_the_language(monkey
|
||||
assert [b.title for b in books] == ["Super-Papagei", "Der Phantomsee", "Sonderband"]
|
||||
|
||||
|
||||
INTRUDER_ROWS = {
|
||||
"name": "Villains",
|
||||
"book_series": [
|
||||
{"position": 1, "book": {
|
||||
"id": 1, "title": "Vicious", "users_count": 1833,
|
||||
"contributions": [{"author": {"name": "V. E. Schwab"}}]}},
|
||||
{"position": 1, "book": {
|
||||
"id": 2, "title": "Die Schoenste im ganzen Land", "users_count": 1,
|
||||
"contributions": [{"author": {"name": "Serena Valentino"}}]}},
|
||||
{"position": 2, "book": {
|
||||
"id": 3, "title": "Coeur de pierre", "users_count": 1,
|
||||
"contributions": [{"author": {"name": "Serena Valentino"}}]}},
|
||||
{"position": 2, "book": {
|
||||
"id": 4, "title": "Cold Hearted", "users_count": 76,
|
||||
"contributions": [{"author": {"name": "Serena Valentino"}}]}},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_hardcover_series_skips_a_foreign_book_filed_under_a_volume(monkeypatch):
|
||||
"""Hardcover lets anyone file a book into a series - "Vicious" sits on volume
|
||||
1 of the Disney Villains and has a German edition and 1833 readers, so both
|
||||
tie breakers would hand it the slot."""
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
import json
|
||||
if "editions" in json.loads(request.content)["query"]:
|
||||
return httpx.Response(200, json={"data": {"editions": [
|
||||
{"book_id": 1, "title": "Vicious - Das Boese in uns"},
|
||||
{"book_id": 2, "title": "Die Schoenste im ganzen Land"},
|
||||
]}})
|
||||
return httpx.Response(200, json={"data": {"series": [INTRUDER_ROWS]}})
|
||||
|
||||
monkeypatch.setattr(hardcover, "TOKEN", "test-token")
|
||||
mock_client(monkeypatch, hardcover, handler)
|
||||
books = asyncio.run(hardcover.series_books("976", "german"))
|
||||
# volume 2 has no German edition: the most read row beats the French one
|
||||
assert [b.title for b in books] == [
|
||||
"Die Schoenste im ganzen Land", "Cold Hearted"]
|
||||
|
||||
|
||||
def test_hardcover_series_survives_a_broken_edition_lookup(monkeypatch):
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
import json
|
||||
|
||||
Reference in new issue
Block a user