f72ebdb149
If the ComicCacher is to be a generic cache for talkers it must assume very little. Current assumptions: - There are issues that can be queried individually by an "Issue ID" and they have a relation to a single series - There are series that can be queried individually by an "Series ID" and they have a relation to zero or more issues - There are Searches that can be queried by the search term and they have a relation to zero or more series Each series and issue have a boolean `complete` attribute which is up to the talker to decide what it means. Data is returned as a tuple ([series, complete] or [issue, complete]) or a list of tuples An issue consists of an ID, an series ID and a binary data attribute which is up to the talker to determine what it means. An series consists of in ID and a binary data attribute which is up to the talker to determine what it means. The data attribute is binary to allow for compression and efficient storage of binary data (e.g. pickle) it is suggested to store it as json or similar text format encoded with utf-8. If the talker is using a website API it is suggested to store the raw response from the server. All caches automatically expire 7 days after insertion.
156 lines
4.2 KiB
Python
156 lines
4.2 KiB
Python
from __future__ import annotations
|
|
|
|
import comicapi.genericmetadata
|
|
from comicapi import utils
|
|
|
|
search_results = [
|
|
dict(
|
|
count_of_issues=1,
|
|
count_of_volumes=1,
|
|
description="this is a description",
|
|
id="1",
|
|
image_url="https://test.org/image/1",
|
|
name="test",
|
|
publisher="test",
|
|
start_year=0,
|
|
aliases=[],
|
|
genres=[],
|
|
format=None,
|
|
),
|
|
dict(
|
|
count_of_issues=1,
|
|
count_of_volumes=1,
|
|
description="this is a description",
|
|
id="2",
|
|
image_url="https://test.org/image/2",
|
|
name="test 2",
|
|
publisher="test",
|
|
start_year=0,
|
|
aliases=[],
|
|
genres=[],
|
|
format=None,
|
|
),
|
|
]
|
|
|
|
alt_covers = [
|
|
{"issue_id": 1, "url_list": ["https://test.org/image/1"]},
|
|
{"issue_id": 2, "url_list": ["https://test.org/image/2"]},
|
|
]
|
|
|
|
select_details = [
|
|
{
|
|
"issue_id": 1,
|
|
"image_url": "https://test.org/image/1",
|
|
"thumb_image_url": "https://test.org/thumb/1",
|
|
"cover_date": "1998",
|
|
"site_detail_url": "https://test.org/1",
|
|
},
|
|
{
|
|
"issue_id": 2,
|
|
"image_url": "https://test.org/image/2",
|
|
"thumb_image_url": "https://test.org/thumb/2",
|
|
"cover_date": "1998",
|
|
"site_detail_url": "https://test.org/2",
|
|
},
|
|
]
|
|
|
|
# Used to test GenericMetadata.overlay
|
|
metadata = [
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="test", issue="2", title="never"),
|
|
comicapi.genericmetadata.md_test.replace(series="test", issue="2", title="never"),
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="", issue="2", title="never"),
|
|
comicapi.genericmetadata.md_test.replace(series=None, issue="2", title="never"),
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="", issue="", title="never"),
|
|
comicapi.genericmetadata.md_test.replace(series=None, issue=None, title="never"),
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="", issue=None, title="never"),
|
|
comicapi.genericmetadata.md_test.replace(series=None, issue="1", title="never"),
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(),
|
|
comicapi.genericmetadata.md_test.copy(),
|
|
),
|
|
]
|
|
|
|
metadata_keys = [
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(),
|
|
{
|
|
"issue_count": 6,
|
|
"issue_number": "1",
|
|
"month": 10,
|
|
"series": "Cory Doctorow's Futuristic Tales of the Here and Now",
|
|
"year": 2007,
|
|
},
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="test"),
|
|
{
|
|
"issue_count": 6,
|
|
"issue_number": "1",
|
|
"month": 10,
|
|
"series": "test",
|
|
"year": 2007,
|
|
},
|
|
),
|
|
(
|
|
comicapi.genericmetadata.GenericMetadata(series="test", issue="3"),
|
|
{
|
|
"issue_count": 6,
|
|
"issue_number": "3",
|
|
"month": 10,
|
|
"series": "test",
|
|
"year": 2007,
|
|
},
|
|
),
|
|
]
|
|
|
|
credits = [
|
|
(comicapi.genericmetadata.md_test, "writer", "Dara Naraghi"),
|
|
(comicapi.genericmetadata.md_test, "writeR", "Dara Naraghi"),
|
|
(
|
|
comicapi.genericmetadata.md_test.replace(
|
|
credits=[{"person": "Dara Naraghi", "role": "writer"}, {"person": "Dara Naraghi", "role": "writer"}]
|
|
),
|
|
"writeR",
|
|
"Dara Naraghi",
|
|
),
|
|
]
|
|
|
|
imprints = [
|
|
("marvel", ("", "Marvel")),
|
|
("marvel comics", ("", "Marvel")),
|
|
("aircel", ("Aircel Comics", "Marvel")),
|
|
("nothing", ("", "nothing")),
|
|
]
|
|
|
|
additional_imprints = [
|
|
("test", ("Test", "Marvel")),
|
|
("temp", ("Temp", "DC Comics")),
|
|
]
|
|
|
|
all_imprints = imprints + additional_imprints
|
|
|
|
seed_imprints = {
|
|
"Marvel": utils.ImprintDict("Marvel", {"marvel comics": "", "aircel": "Aircel Comics"}),
|
|
}
|
|
|
|
additional_seed_imprints = {
|
|
"Marvel": utils.ImprintDict("Marvel", {"test": "Test"}),
|
|
"DC Comics": utils.ImprintDict("DC Comics", {"temp": "Temp"}),
|
|
}
|
|
|
|
all_seed_imprints = {
|
|
"Marvel": seed_imprints["Marvel"].copy(),
|
|
"DC Comics": additional_seed_imprints["DC Comics"].copy(),
|
|
}
|
|
all_seed_imprints["Marvel"].update(additional_seed_imprints["Marvel"])
|
|
|
|
conflicting_seed_imprints = {"Marvel": {"test": "Never"}}
|