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 responses.GET, "https://example.com/book/abcd", json=self.edition_data
) )
with patch("bookwyrm.connectors.abstract_connector.load_more_data.delay"): with patch("bookwyrm.connectors.abstract_connector.load_more_data.delay"):
result = self.connector.get_or_create_book( result = self.connector.get_or_create_book("https://example.com/book/abcd")
"https://example.com/book/abcd"
)
self.assertEqual(result, self.book) self.assertEqual(result, self.book)
self.assertEqual(models.Edition.objects.count(), 1) self.assertEqual(models.Edition.objects.count(), 1)
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 @responses.activate
def test_expand_book_data(self): def test_expand_book_data(self):
"""given a book, get more editions""" """given a book, get more editions"""
work = models.Work.objects.create( work = models.Work.objects.create(title="Test Work", openlibrary_key="OL1234W")
title="Test Work", openlibrary_key="OL1234W" edition = models.Edition.objects.create(title="Test Edition", parent_work=work)
)
edition = models.Edition.objects.create(
title="Test Edition", parent_work=work
)
responses.add( responses.add(
responses.GET, responses.GET,
@ -232,9 +228,7 @@ class Openlibrary(TestCase):
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data" "bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
) as mock: ) as mock:
mock.return_value = [] mock.return_value = []
result = self.connector.create_edition_from_data( result = self.connector.create_edition_from_data(work, self.edition_data)
work, self.edition_data
)
self.assertEqual(result.parent_work, work) self.assertEqual(result.parent_work, work)
self.assertEqual(result.title, "Sabriel") self.assertEqual(result.title, "Sabriel")
self.assertEqual(result.isbn_10, "0060273224") self.assertEqual(result.isbn_10, "0060273224")

View file

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

View file

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

View file

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

View file

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