This commit is contained in:
Joachim 2021-05-27 23:21:47 +02:00
parent f8df501239
commit 878cc5cb17
6 changed files with 17 additions and 6 deletions

View file

@ -113,7 +113,9 @@ class AbstractConnector(TestCase):
) )
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"): with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
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("https://example.com/book/abcd") result = self.connector.get_or_create_book(
"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

@ -235,7 +235,9 @@ 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(work, self.edition_data) result = self.connector.create_edition_from_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

@ -256,7 +256,10 @@ class ActivitypubFields(TestCase):
# test receiving an unknown remote id and loading data # test receiving an unknown remote id and loading data
responses.add( responses.add(
responses.GET, "https://example.com/user/mouse", json=userdata, status=200 responses.GET,
"https://example.com/user/mouse",
json=userdata,
status=200,
) )
with patch("bookwyrm.models.user.set_remote_server.delay"): with patch("bookwyrm.models.user.set_remote_server.delay"):
value = instance.field_from_activity("https://example.com/user/mouse") value = instance.field_from_activity("https://example.com/user/mouse")

View file

@ -175,7 +175,9 @@ class ImportJob(TestCase):
with patch( with patch(
"bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data" "bookwyrm.connectors.openlibrary.Connector." "get_authors_from_data"
): ):
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"): with patch(
"bookwyrm.preview_images.generate_edition_preview_image_task.delay"
):
book = self.item_1.get_book_from_isbn() book = self.item_1.get_book_from_isbn()
self.assertEqual(book.title, "Sabriel") self.assertEqual(book.title, "Sabriel")

View file

@ -163,7 +163,9 @@ class InboxCreate(TestCase):
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
} }
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"): with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
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) 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

@ -98,7 +98,7 @@ class InboxUpdate(TestCase):
del userdata["icon"] del userdata["icon"]
self.assertIsNone(self.remote_user.name) self.assertIsNone(self.remote_user.name)
self.assertFalse(self.remote_user.discoverable) self.assertFalse(self.remote_user.discoverable)
with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"): with patch("bookwyrm.preview_images.generate_user_preview_image_task.delay"):
views.inbox.activity_task( views.inbox.activity_task(
{ {