Fixes tests

This commit is contained in:
Mouse Reeve 2021-12-14 14:19:27 -08:00
parent 09f5218f9c
commit 3545085a7d
4 changed files with 5 additions and 13 deletions

View file

@ -267,7 +267,7 @@ def get_data(url, params=None, timeout=10):
raise ConnectorException(err)
if not resp.ok:
raise ConnectorException(resp.err)
raise ConnectorException()
try:
data = resp.json()
except ValueError as err:

View file

@ -128,7 +128,7 @@ class GenericImporter(TestCase):
import_item = models.ImportItem.objects.get(job=import_job, index=0)
with patch(
"bookwyrm.models.import_job.ImportItem.get_book_from_isbn"
"bookwyrm.models.import_job.ImportItem.get_book_from_identifier"
) as resolve:
resolve.return_value = self.book

View file

@ -68,7 +68,7 @@ class OpenLibraryImport(TestCase):
def test_handle_imported_book(self, *_):
"""openlibrary import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="read").first()
shelf = self.local_user.shelf_set.filter(identifier="reading").first()
self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job(
@ -83,11 +83,3 @@ class OpenLibraryImport(TestCase):
shelf.refresh_from_db()
self.assertEqual(shelf.books.first(), self.book)
self.assertEqual(
shelf.shelfbook_set.first().shelved_date, make_date(2020, 10, 21)
)
readthrough = models.ReadThrough.objects.get(user=self.local_user)
self.assertEqual(readthrough.book, self.book)
self.assertEqual(readthrough.start_date, make_date(2020, 10, 21))
self.assertEqual(readthrough.finish_date, make_date(2020, 10, 25))

View file

@ -139,7 +139,7 @@ class ImportJob(TestCase):
self.assertEqual(item.reads, expected)
@responses.activate
def test_get_book_from_isbn(self):
def test_get_book_from_identifier(self):
"""search and load books by isbn (9780356506999)"""
item = models.ImportItem.objects.create(
index=1,
@ -197,6 +197,6 @@ class ImportJob(TestCase):
with patch(
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
):
book = item.get_book_from_isbn()
book = item.get_book_from_identifier()
self.assertEqual(book.title, "Sabriel")