Fixes tests
This commit is contained in:
parent
50ca16a46f
commit
6dd7eebd98
|
@ -67,7 +67,7 @@ class Connector(AbstractConnector):
|
||||||
extracted = list(data.get("entities").values())
|
extracted = list(data.get("entities").values())
|
||||||
try:
|
try:
|
||||||
data = extracted[0]
|
data = extracted[0]
|
||||||
except KeyError:
|
except (KeyError, IndexError):
|
||||||
raise ConnectorException("Invalid book data")
|
raise ConnectorException("Invalid book data")
|
||||||
# flatten the data so that images, uri, and claims are on the same level
|
# flatten the data so that images, uri, and claims are on the same level
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -269,10 +269,14 @@ class Inventaire(TestCase):
|
||||||
responses.GET,
|
responses.GET,
|
||||||
"https://inventaire.io/?action=by-uris&uris=hello",
|
"https://inventaire.io/?action=by-uris&uris=hello",
|
||||||
)
|
)
|
||||||
data = {"wdt:P629": "hello"}
|
data = {"wdt:P629": ["hello"]}
|
||||||
self.connector.get_work_from_edition_data(data)
|
with patch("bookwyrm.connectors.inventaire.Connector.get_book_data") as mock:
|
||||||
|
self.connector.get_work_from_edition_data(data)
|
||||||
|
self.assertEqual(mock.call_count, 1)
|
||||||
|
args = mock.call_args[0]
|
||||||
|
self.assertEqual(args[0], "https://inventaire.io?action=by-uris&uris=hello")
|
||||||
|
|
||||||
data = {"wdt:P629": None}
|
data = {"wdt:P629": [None]}
|
||||||
with self.assertRaises(ConnectorException):
|
with self.assertRaises(ConnectorException):
|
||||||
self.connector.get_work_from_edition_data(data)
|
self.connector.get_work_from_edition_data(data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue