Python formatting

This commit is contained in:
Mouse Reeve 2021-08-02 16:07:39 -07:00
parent 6d8bced0f1
commit 0a7afdb1c0
6 changed files with 9 additions and 27 deletions

View file

@ -111,9 +111,7 @@ class AbstractConnector(TestCase):
responses.GET, "https://example.com/book/abcd", json=self.edition_data
)
with patch("bookwyrm.connectors.abstract_connector.load_more_data.delay"):
result = self.connector.get_or_create_book(
"https://example.com/book/abcd"
)
result = self.connector.get_or_create_book("https://example.com/book/abcd")
self.assertEqual(result, self.book)
self.assertEqual(models.Edition.objects.count(), 1)
self.assertEqual(models.Edition.objects.count(), 1)

View file

@ -178,12 +178,8 @@ class Openlibrary(TestCase):
@responses.activate
def test_expand_book_data(self):
"""given a book, get more editions"""
work = models.Work.objects.create(
title="Test Work", openlibrary_key="OL1234W"
)
edition = models.Edition.objects.create(
title="Test Edition", parent_work=work
)
work = models.Work.objects.create(title="Test Work", openlibrary_key="OL1234W")
edition = models.Edition.objects.create(title="Test Edition", parent_work=work)
responses.add(
responses.GET,
@ -232,9 +228,7 @@ class Openlibrary(TestCase):
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
) as mock:
mock.return_value = []
result = self.connector.create_edition_from_data(
work, self.edition_data
)
result = self.connector.create_edition_from_data(work, self.edition_data)
self.assertEqual(result.parent_work, work)
self.assertEqual(result.title, "Sabriel")
self.assertEqual(result.isbn_10, "0060273224")

View file

@ -16,9 +16,7 @@ class Shelf(TestCase):
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
)
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
title="test book", parent_work=work
)
self.book = models.Edition.objects.create(title="test book", parent_work=work)
def test_remote_id(self):
"""shelves use custom remote ids"""

View file

@ -123,12 +123,8 @@ class TemplateTags(TestCase):
def test_get_boosted(self, *_):
"""load a boosted status"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
status = models.Review.objects.create(
user=self.remote_user, book=self.book
)
boost = models.Boost.objects.create(
user=self.user, boosted_status=status
)
status = models.Review.objects.create(user=self.remote_user, book=self.book)
boost = models.Boost.objects.create(user=self.user, boosted_status=status)
boosted = status_display.get_boosted(boost)
self.assertIsInstance(boosted, models.Review)
self.assertEqual(boosted, status)

View file

@ -157,9 +157,7 @@ class InboxCreate(TestCase):
"rating": 3,
"@context": "https://www.w3.org/ns/activitystreams",
}
with patch(
"bookwyrm.activitystreams.ActivityStream.add_status"
) as redis_mock:
with patch("bookwyrm.activitystreams.ActivityStream.add_status") as redis_mock:
views.inbox.activity_task(activity)
self.assertTrue(redis_mock.called)
rating = models.ReviewRating.objects.first()

View file

@ -204,9 +204,7 @@ class BookViews(TestCase):
"""updates user's relationships to a book"""
work = models.Work.objects.create(title="test work")
edition1 = models.Edition.objects.create(title="first ed", parent_work=work)
edition2 = models.Edition.objects.create(
title="second ed", parent_work=work
)
edition2 = models.Edition.objects.create(title="second ed", parent_work=work)
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
shelf = models.Shelf.objects.create(name="Test Shelf", user=self.local_user)
models.ShelfBook.objects.create(