forked from mirrors/bookwyrm
Adds a couple more tests and test data
This commit is contained in:
parent
fc095a087c
commit
0a41503572
4 changed files with 381 additions and 0 deletions
|
@ -66,3 +66,73 @@ class Inventaire(TestCase):
|
|||
formatted.cover,
|
||||
"https://covers.inventaire.io/img/entities/ddb32e115a28dcc0465023869ba19f6868ec4042",
|
||||
)
|
||||
|
||||
def test_get_cover_url(self):
|
||||
"""figure out where the cover image is"""
|
||||
cover_blob = {"url": "/img/entities/d46a8"}
|
||||
result = self.connector.get_cover_url(cover_blob)
|
||||
self.assertEqual(result, "https://covers.inventaire.io/img/entities/d46a8")
|
||||
|
||||
cover_blob = {
|
||||
"url": "https://commons.wikimedia.org/wiki/Special:FilePath/The%20Moonstone%201st%20ed.jpg?width=1000",
|
||||
"file": "The Moonstone 1st ed.jpg",
|
||||
"credits": {
|
||||
"text": "Wikimedia Commons",
|
||||
"url": "https://commons.wikimedia.org/wiki/File:The Moonstone 1st ed.jpg",
|
||||
},
|
||||
}
|
||||
|
||||
result = self.connector.get_cover_url(cover_blob)
|
||||
self.assertEqual(
|
||||
result,
|
||||
"https://commons.wikimedia.org/wiki/Special:FilePath/The%20Moonstone%201st%20ed.jpg?width=1000",
|
||||
)
|
||||
|
||||
@responses.activate
|
||||
def test_resolve_keys(self):
|
||||
"""makes an http request"""
|
||||
responses.add(
|
||||
responses.GET,
|
||||
"https://inventaire.io?action=by-uris&uris=wd:Q465821",
|
||||
json={
|
||||
"entities": {
|
||||
"wd:Q465821": {
|
||||
"type": "genre",
|
||||
"labels": {
|
||||
"nl": "briefroman",
|
||||
"en": "epistolary novel",
|
||||
"de-ch": "Briefroman",
|
||||
"en-ca": "Epistolary novel",
|
||||
"nb": "brev- og dagbokroman",
|
||||
},
|
||||
"descriptions": {
|
||||
"en": "novel written as a series of documents",
|
||||
"es": "novela escrita como una serie de documentos",
|
||||
"eo": "romano en la formo de serio de leteroj",
|
||||
},
|
||||
},
|
||||
"redirects": {},
|
||||
}
|
||||
},
|
||||
)
|
||||
responses.add(
|
||||
responses.GET,
|
||||
"https://inventaire.io?action=by-uris&uris=wd:Q208505",
|
||||
json={
|
||||
"entities": {
|
||||
"wd:Q208505": {
|
||||
"type": "genre",
|
||||
"labels": {
|
||||
"en": "crime novel",
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
keys = [
|
||||
"wd:Q465821",
|
||||
"wd:Q208505",
|
||||
]
|
||||
result = self.connector.resolve_keys(keys)
|
||||
self.assertEqual(result, ["epistolary novel", "crime novel"])
|
||||
|
|
45
bookwyrm/tests/data/inventaire_edition.json
Normal file
45
bookwyrm/tests/data/inventaire_edition.json
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"entities": {
|
||||
"isbn:9780375757853": {
|
||||
"_id": "7beee121a8d9ac345cdf4e9128577723",
|
||||
"_rev": "2-ac318b04b953ca3894deb77fee28211c",
|
||||
"type": "edition",
|
||||
"labels": {},
|
||||
"claims": {
|
||||
"wdt:P31": [
|
||||
"wd:Q3331189"
|
||||
],
|
||||
"wdt:P212": [
|
||||
"978-0-375-75785-3"
|
||||
],
|
||||
"wdt:P957": [
|
||||
"0-375-75785-6"
|
||||
],
|
||||
"wdt:P407": [
|
||||
"wd:Q1860"
|
||||
],
|
||||
"wdt:P1476": [
|
||||
"The Moonstone"
|
||||
],
|
||||
"wdt:P577": [
|
||||
"2001"
|
||||
],
|
||||
"wdt:P629": [
|
||||
"wd:Q2362563"
|
||||
],
|
||||
"invp:P2": [
|
||||
"d46a8eac7555afa479b8bbb5149f35858e8e19c4"
|
||||
]
|
||||
},
|
||||
"created": 1495452670475,
|
||||
"updated": 1541032981834,
|
||||
"version": 3,
|
||||
"uri": "isbn:9780375757853",
|
||||
"originalLang": "en",
|
||||
"image": {
|
||||
"url": "/img/entities/d46a8eac7555afa479b8bbb5149f35858e8e19c4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"redirects": {}
|
||||
}
|
111
bookwyrm/tests/data/inventaire_search.json
Normal file
111
bookwyrm/tests/data/inventaire_search.json
Normal file
|
@ -0,0 +1,111 @@
|
|||
{
|
||||
"results": [
|
||||
{
|
||||
"id": "Q7766679",
|
||||
"type": "works",
|
||||
"uri": "wd:Q7766679",
|
||||
"label": "The Stories of Vladimir Nabokov",
|
||||
"description": "book by Vladimir Nabokov",
|
||||
"image": [
|
||||
"ddb32e115a28dcc0465023869ba19f6868ec4042"
|
||||
],
|
||||
"_score": 25.180836,
|
||||
"_popularity": 4
|
||||
},
|
||||
{
|
||||
"id": "Q47407212",
|
||||
"type": "works",
|
||||
"uri": "wd:Q47407212",
|
||||
"label": "Conversations with Vladimir Nabokov",
|
||||
"description": "book edited by Robert Golla",
|
||||
"image": [],
|
||||
"_score": 24.41498,
|
||||
"_popularity": 2
|
||||
},
|
||||
{
|
||||
"id": "Q6956987",
|
||||
"type": "works",
|
||||
"uri": "wd:Q6956987",
|
||||
"label": "Nabokov's Congeries",
|
||||
"description": "book by Vladimir Nabokov",
|
||||
"image": [],
|
||||
"_score": 22.343866,
|
||||
"_popularity": 2
|
||||
},
|
||||
{
|
||||
"id": "Q6956986",
|
||||
"type": "works",
|
||||
"uri": "wd:Q6956986",
|
||||
"label": "Nabokov's Butterflies",
|
||||
"description": "book by Brian Boyd",
|
||||
"image": [],
|
||||
"_score": 22.343866,
|
||||
"_popularity": 2
|
||||
},
|
||||
{
|
||||
"id": "Q47472170",
|
||||
"type": "works",
|
||||
"uri": "wd:Q47472170",
|
||||
"label": "A Reader's Guide to Nabokov's \"Lolita\"",
|
||||
"description": "book by Julian W. Connolly",
|
||||
"image": [],
|
||||
"_score": 19.482553,
|
||||
"_popularity": 2
|
||||
},
|
||||
{
|
||||
"id": "Q7936323",
|
||||
"type": "works",
|
||||
"uri": "wd:Q7936323",
|
||||
"label": "Visiting Mrs Nabokov: And Other Excursions",
|
||||
"description": "book by Martin Amis",
|
||||
"image": [],
|
||||
"_score": 18.684965,
|
||||
"_popularity": 2
|
||||
},
|
||||
{
|
||||
"id": "1732d81bf7376e04da27568a778561a4",
|
||||
"type": "works",
|
||||
"uri": "inv:1732d81bf7376e04da27568a778561a4",
|
||||
"label": "Nabokov's Dark Cinema",
|
||||
"image": [
|
||||
"7512805a53da569b11bf29cc3fb272c969619749"
|
||||
],
|
||||
"_score": 16.56681,
|
||||
"_popularity": 1
|
||||
},
|
||||
{
|
||||
"id": "00f118336b02219e1bddc8fa93c56050",
|
||||
"type": "works",
|
||||
"uri": "inv:00f118336b02219e1bddc8fa93c56050",
|
||||
"label": "The Cambridge Companion to Nabokov",
|
||||
"image": [
|
||||
"0683a059fb95430cfa73334f9eff2ef377f3ae3d"
|
||||
],
|
||||
"_score": 15.502292,
|
||||
"_popularity": 1
|
||||
},
|
||||
{
|
||||
"id": "6e59f968a1cd00dbedeb1964dec47507",
|
||||
"type": "works",
|
||||
"uri": "inv:6e59f968a1cd00dbedeb1964dec47507",
|
||||
"label": "Vladimir Nabokov : selected letters, 1940-1977",
|
||||
"image": [
|
||||
"e3ce8c0ee89d576adf2651a6e5ce55fc6d9f8cb3"
|
||||
],
|
||||
"_score": 15.019735,
|
||||
"_popularity": 1
|
||||
},
|
||||
{
|
||||
"id": "Q127149",
|
||||
"type": "works",
|
||||
"uri": "wd:Q127149",
|
||||
"label": "Lolita",
|
||||
"description": "novel by Vladimir Nabokov",
|
||||
"image": [
|
||||
"51cbfdbf7257b1a6bb3ea3fbb167dbce1fb44a0e"
|
||||
],
|
||||
"_score": 13.458428,
|
||||
"_popularity": 32
|
||||
}
|
||||
]
|
||||
}
|
155
bookwyrm/tests/data/inventaire_work.json
Normal file
155
bookwyrm/tests/data/inventaire_work.json
Normal file
|
@ -0,0 +1,155 @@
|
|||
{
|
||||
"entities": {
|
||||
"wd:Q2362563": {
|
||||
"type": "work",
|
||||
"labels": {
|
||||
"zh-hans": "月亮宝石",
|
||||
"zh-hant": "月亮寶石",
|
||||
"zh-hk": "月光石",
|
||||
"zh-tw": "月光石",
|
||||
"cy": "The Moonstone",
|
||||
"ml": "ദ മൂൺസ്റ്റോൺ",
|
||||
"ja": "月長石",
|
||||
"te": "ది మూన్ స్టోన్",
|
||||
"ru": "Лунный камень",
|
||||
"fr": "La Pierre de lune",
|
||||
"en": "The Moonstone",
|
||||
"es": "La piedra lunar",
|
||||
"it": "La Pietra di Luna",
|
||||
"zh": "月亮宝石",
|
||||
"pl": "Kamień Księżycowy",
|
||||
"sr": "2 Јн",
|
||||
"ta": "moon stone",
|
||||
"ar": "حجر القمر",
|
||||
"fa": "ماهالماس",
|
||||
"uk": "Місячний камінь",
|
||||
"nl": "The Moonstone",
|
||||
"de": "Der Monddiamant",
|
||||
"sl": "Diamant",
|
||||
"sv": "Månstenen",
|
||||
"he": "אבן הירח",
|
||||
"eu": "Ilargi-harriak",
|
||||
"bg": "Лунният камък",
|
||||
"ka": "მთვარის ქვა",
|
||||
"eo": "La Lunŝtono",
|
||||
"hy": "Լուսնաքար",
|
||||
"ro": "Piatra Lunii",
|
||||
"ca": "The Moonstone",
|
||||
"is": "The Moonstone"
|
||||
},
|
||||
"descriptions": {
|
||||
"it": "romanzo scritto da Wilkie Collins",
|
||||
"en": "novel by Wilkie Collins",
|
||||
"de": "Buch von Wilkie Collins",
|
||||
"nl": "boek van Wilkie Collins",
|
||||
"ru": "роман Уилки Коллинза",
|
||||
"he": "רומן מאת וילקי קולינס",
|
||||
"ar": "رواية من تأليف ويلكي كولينز",
|
||||
"fr": "livre de Wilkie Collins",
|
||||
"es": "libro de Wilkie Collins",
|
||||
"bg": "роман на Уилки Колинс",
|
||||
"ka": "უილკი კოლინსის რომანი",
|
||||
"eo": "angalingva romano far Wilkie Collins",
|
||||
"ro": "roman de Wilkie Collins"
|
||||
},
|
||||
"aliases": {
|
||||
"zh": [
|
||||
"月光石"
|
||||
],
|
||||
"ml": [
|
||||
"The Moonstone"
|
||||
],
|
||||
"fr": [
|
||||
"The Moonstone"
|
||||
],
|
||||
"it": [
|
||||
"Il diamante indiano",
|
||||
"La pietra della luna",
|
||||
"La maledizione del diamante indiano"
|
||||
],
|
||||
"ro": [
|
||||
"The Moonstone"
|
||||
]
|
||||
},
|
||||
"claims": {
|
||||
"wdt:P18": [
|
||||
"The Moonstone 1st ed.jpg"
|
||||
],
|
||||
"wdt:P31": [
|
||||
"wd:Q7725634"
|
||||
],
|
||||
"wdt:P50": [
|
||||
"wd:Q210740"
|
||||
],
|
||||
"wdt:P123": [
|
||||
"wd:Q4457856"
|
||||
],
|
||||
"wdt:P136": [
|
||||
"wd:Q465821",
|
||||
"wd:Q208505",
|
||||
"wd:Q10992055"
|
||||
],
|
||||
"wdt:P156": [
|
||||
"wd:Q7228798"
|
||||
],
|
||||
"wdt:P268": [
|
||||
"12496407z"
|
||||
],
|
||||
"wdt:P407": [
|
||||
"wd:Q7979"
|
||||
],
|
||||
"wdt:P577": [
|
||||
"1868"
|
||||
],
|
||||
"wdt:P1433": [
|
||||
"wd:Q21"
|
||||
],
|
||||
"wdt:P1476": [
|
||||
"The Moonstone"
|
||||
],
|
||||
"wdt:P1680": [
|
||||
"A Romance"
|
||||
],
|
||||
"wdt:P2034": [
|
||||
"155"
|
||||
]
|
||||
},
|
||||
"sitelinks": {
|
||||
"arwiki": "حجر القمر (رواية)",
|
||||
"bgwiki": "Лунният камък (роман)",
|
||||
"cywiki": "The Moonstone",
|
||||
"dewiki": "Der Monddiamant",
|
||||
"enwiki": "The Moonstone",
|
||||
"enwikisource": "The Moonstone",
|
||||
"eswiki": "La piedra lunar",
|
||||
"euwiki": "Ilargi-harria",
|
||||
"fawiki": "ماهالماس",
|
||||
"frwiki": "La Pierre de lune (roman de Wilkie Collins)",
|
||||
"hewiki": "אבן הירח",
|
||||
"hywiki": "Լուսնաքար",
|
||||
"iswiki": "The Moonstone",
|
||||
"itwiki": "La pietra di Luna",
|
||||
"jawiki": "月長石 (小説)",
|
||||
"mlwiki": "ദ മൂൺസ്റ്റോൺ",
|
||||
"plwiki": "Kamień Księżycowy (powieść)",
|
||||
"ruwiki": "Лунный камень (роман)",
|
||||
"slwiki": "Diamant (roman)",
|
||||
"srwikisource": "Нови завјет (Караџић) / 2. Јованова",
|
||||
"svwiki": "Månstenen",
|
||||
"tewiki": "ది మూన్స్టోన్",
|
||||
"ukwiki": "Місячний камінь (роман)",
|
||||
"zhwiki": "月亮宝石"
|
||||
},
|
||||
"uri": "wd:Q2362563",
|
||||
"image": {
|
||||
"url": "https://commons.wikimedia.org/wiki/Special:FilePath/The%20Moonstone%201st%20ed.jpg?width=1000",
|
||||
"file": "The Moonstone 1st ed.jpg",
|
||||
"credits": {
|
||||
"text": "Wikimedia Commons",
|
||||
"url": "https://commons.wikimedia.org/wiki/File:The Moonstone 1st ed.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"redirects": {}
|
||||
}
|
Loading…
Reference in a new issue