forked from mirrors/bookwyrm
Reformat tests using black
Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
22fcb61fb2
commit
62c7661fb9
6 changed files with 36 additions and 12 deletions
|
@ -46,11 +46,15 @@ class CalibreImport(TestCase):
|
|||
)
|
||||
self.assertEqual(len(import_items), 1)
|
||||
self.assertEqual(import_items[0].index, 0)
|
||||
self.assertEqual(import_items[0].normalized_data["title"], "That Ain't Witchcraft")
|
||||
self.assertEqual(
|
||||
import_items[0].normalized_data["title"], "That Ain't Witchcraft"
|
||||
)
|
||||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""calibre import added a book, this adds related connections"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.TO_READ).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.TO_READ
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -84,7 +84,9 @@ class GoodreadsImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""goodreads import added a book, this adds related connections"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.READ_FINISHED).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -174,7 +174,9 @@ class GenericImporter(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""import added a book, this adds related connections"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.READ_FINISHED).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
@ -193,7 +195,9 @@ class GenericImporter(TestCase):
|
|||
def test_handle_imported_book_already_shelved(self, *_):
|
||||
"""import added a book, this adds related connections"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.TO_READ).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.TO_READ
|
||||
).first()
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=shelf,
|
||||
user=self.local_user,
|
||||
|
@ -217,12 +221,16 @@ class GenericImporter(TestCase):
|
|||
shelf.shelfbook_set.first().shelved_date, make_date(2020, 2, 2)
|
||||
)
|
||||
self.assertIsNone(
|
||||
self.local_user.shelf_set.get(identifier=models.Shelf.READ_FINISHED).books.first()
|
||||
self.local_user.shelf_set.get(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).books.first()
|
||||
)
|
||||
|
||||
def test_handle_import_twice(self, *_):
|
||||
"""re-importing books"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.READ_FINISHED).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).first()
|
||||
import_job = self.importer.create_job(
|
||||
self.local_user, self.csv, False, "public"
|
||||
)
|
||||
|
|
|
@ -93,7 +93,9 @@ class LibrarythingImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""librarything import added a book, this adds related connections"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.READ_FINISHED).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
@ -117,7 +119,9 @@ class LibrarythingImport(TestCase):
|
|||
def test_handle_imported_book_already_shelved(self, *_):
|
||||
"""librarything import added a book, this adds related connections"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.TO_READ).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.TO_READ
|
||||
).first()
|
||||
models.ShelfBook.objects.create(
|
||||
shelf=shelf, user=self.local_user, book=self.book
|
||||
)
|
||||
|
@ -135,7 +139,9 @@ class LibrarythingImport(TestCase):
|
|||
shelf.refresh_from_db()
|
||||
self.assertEqual(shelf.books.first(), self.book)
|
||||
self.assertIsNone(
|
||||
self.local_user.shelf_set.get(identifier=models.Shelf.READ_FINISHED).books.first()
|
||||
self.local_user.shelf_set.get(
|
||||
identifier=models.Shelf.READ_FINISHED
|
||||
).books.first()
|
||||
)
|
||||
|
||||
readthrough = models.ReadThrough.objects.get(user=self.local_user)
|
||||
|
|
|
@ -70,7 +70,9 @@ 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=models.Shelf.READING).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.READING
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -62,7 +62,9 @@ class StorygraphImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""storygraph import added a book, this adds related connections"""
|
||||
shelf = self.local_user.shelf_set.filter(identifier=models.Shelf.TO_READ).first()
|
||||
shelf = self.local_user.shelf_set.filter(
|
||||
identifier=models.Shelf.TO_READ
|
||||
).first()
|
||||
self.assertIsNone(shelf.books.first())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
Loading…
Reference in a new issue