Adds openlibrary keys to data

This commit is contained in:
Mouse Reeve 2021-12-14 12:42:56 -08:00
parent bb69c32a6c
commit 4f1d4d9bc0
2 changed files with 14 additions and 0 deletions

View file

@ -6,3 +6,8 @@ class OpenLibraryImporter(Importer):
"""csv downloads from OpenLibrary"""
service = "OpenLibrary"
def __init__(self, *args, **kwargs):
self.row_mappings_guesses.append(("openlibrary_key", ["edition id"]))
self.row_mappings_guesses.append(("openlibrary_work_key", ["work id"]))
super().__init__(*args, **kwargs)

View file

@ -56,6 +56,15 @@ class OpenLibraryImport(TestCase):
self.assertEqual(import_items[1].data["Edition Id"], "OL7798182M")
self.assertEqual(import_items[0].normalized_data["shelf"], "reading")
self.assertIsNone(import_items[0].normalized_data["openlibrary_key"])
self.assertEqual(
import_items[0].normalized_data["openlibrary_work_key"],
"OL102749W"
)
self.assertEqual(
import_items[1].normalized_data["openlibrary_key"],
"OL7798182M"
)
self.assertEqual(import_items[2].normalized_data["shelf"], "to-read")
self.assertEqual(import_items[3].normalized_data["shelf"], "read")