forked from mirrors/bookwyrm
iUpdates storygraph tests
This commit is contained in:
parent
5967834805
commit
efcf7824dd
2 changed files with 12 additions and 6 deletions
|
@ -77,7 +77,9 @@ class Importer:
|
||||||
def get_shelf(self, normalized_row):
|
def get_shelf(self, normalized_row):
|
||||||
"""determine which shelf to use"""
|
"""determine which shelf to use"""
|
||||||
shelf_name = normalized_row["shelf"]
|
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
|
return shelf[0] if shelf else None
|
||||||
|
|
||||||
def normalize_row(self, entry, mappings): # pylint: disable=no-self-use
|
def normalize_row(self, entry, mappings): # pylint: disable=no-self-use
|
||||||
|
|
|
@ -52,10 +52,12 @@ class StorygraphImport(TestCase):
|
||||||
import_items = models.ImportItem.objects.filter(job=import_job).all()
|
import_items = models.ImportItem.objects.filter(job=import_job).all()
|
||||||
self.assertEqual(len(import_items), 2)
|
self.assertEqual(len(import_items), 2)
|
||||||
self.assertEqual(import_items[0].index, 0)
|
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].index, 1)
|
||||||
self.assertEqual(import_items[1].data["Title"], "Subprime Attention Crisis")
|
self.assertEqual(
|
||||||
self.assertEqual(import_items[1].data["My Rating"], 5.0)
|
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, *_):
|
def test_create_retry_job(self, *_):
|
||||||
"""trying again with items that didn't import"""
|
"""trying again with items that didn't import"""
|
||||||
|
@ -75,9 +77,11 @@ class StorygraphImport(TestCase):
|
||||||
retry_items = models.ImportItem.objects.filter(job=retry).all()
|
retry_items = models.ImportItem.objects.filter(job=retry).all()
|
||||||
self.assertEqual(len(retry_items), 2)
|
self.assertEqual(len(retry_items), 2)
|
||||||
self.assertEqual(retry_items[0].index, 0)
|
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].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, *_):
|
def test_handle_imported_book(self, *_):
|
||||||
"""storygraph import added a book, this adds related connections"""
|
"""storygraph import added a book, this adds related connections"""
|
||||||
|
|
Loading…
Reference in a new issue