From efcf7824dd47de77c3cc2e0bcc972bbd131b05af Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 11 Nov 2021 12:39:12 -0800 Subject: [PATCH] iUpdates storygraph tests --- bookwyrm/importers/importer.py | 4 +++- bookwyrm/tests/importers/test_storygraph_import.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bookwyrm/importers/importer.py b/bookwyrm/importers/importer.py index 0233ee3d..cf7841e6 100644 --- a/bookwyrm/importers/importer.py +++ b/bookwyrm/importers/importer.py @@ -77,7 +77,9 @@ class Importer: def get_shelf(self, normalized_row): """determine which shelf to use""" shelf_name = normalized_row["shelf"] - shelf = [s for (s, gs) in self.shelf_mapping_guesses if shelf_name in gs] + shelf = [ + s for (s, gs) in self.shelf_mapping_guesses.items() if shelf_name in gs + ] return shelf[0] if shelf else None def normalize_row(self, entry, mappings): # pylint: disable=no-self-use diff --git a/bookwyrm/tests/importers/test_storygraph_import.py b/bookwyrm/tests/importers/test_storygraph_import.py index 91a5dfa6..2f0fd7ef 100644 --- a/bookwyrm/tests/importers/test_storygraph_import.py +++ b/bookwyrm/tests/importers/test_storygraph_import.py @@ -52,10 +52,12 @@ class StorygraphImport(TestCase): import_items = models.ImportItem.objects.filter(job=import_job).all() self.assertEqual(len(import_items), 2) self.assertEqual(import_items[0].index, 0) - self.assertEqual(import_items[0].data["Title"], "Always Coming Home") + self.assertEqual(import_items[0].normalized_data["title"], "Always Coming Home") self.assertEqual(import_items[1].index, 1) - self.assertEqual(import_items[1].data["Title"], "Subprime Attention Crisis") - self.assertEqual(import_items[1].data["My Rating"], 5.0) + self.assertEqual( + import_items[1].normalized_data["title"], "Subprime Attention Crisis" + ) + self.assertEqual(import_items[1].normalized_data["rating"], "5.0") def test_create_retry_job(self, *_): """trying again with items that didn't import""" @@ -75,9 +77,11 @@ class StorygraphImport(TestCase): retry_items = models.ImportItem.objects.filter(job=retry).all() self.assertEqual(len(retry_items), 2) self.assertEqual(retry_items[0].index, 0) - self.assertEqual(retry_items[0].data["Title"], "Always Coming Home") + self.assertEqual(retry_items[0].normalized_data["title"], "Always Coming Home") self.assertEqual(retry_items[1].index, 1) - self.assertEqual(retry_items[1].data["Title"], "Subprime Attention Crisis") + self.assertEqual( + retry_items[1].normalized_data["title"], "Subprime Attention Crisis" + ) def test_handle_imported_book(self, *_): """storygraph import added a book, this adds related connections"""