From 37e29cc735f8b4c01fb225ab78265656f145bca7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 8 Mar 2021 11:11:05 -0800 Subject: [PATCH] Adds tests of creating book with author --- bookwyrm/tests/views/test_book.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bookwyrm/tests/views/test_book.py b/bookwyrm/tests/views/test_book.py index 90b7359d..bba83714 100644 --- a/bookwyrm/tests/views/test_book.py +++ b/bookwyrm/tests/views/test_book.py @@ -169,6 +169,23 @@ class BookViews(TestCase): book = models.Edition.objects.get(title="New Title") self.assertEqual(book.parent_work, self.work) + def test_create_book_with_author(self): + """ create an entirely new book and work """ + view = views.ConfirmEditBook.as_view() + self.local_user.groups.add(self.group) + form = forms.EditionForm() + form.data["title"] = "New Title" + form.data["add_author"] = "Sappho" + form.data["last_edited_by"] = self.local_user.id + request = self.factory.post("", form.data) + request.user = self.local_user + with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): + view(request) + book = models.Edition.objects.get(title="New Title") + self.assertEqual(book.parent_work.title, "New Title") + self.assertEqual(book.authors.first().name, "Sappho") + self.assertEqual(book.authors.first(), book.parent_work.authors.first()) + def test_switch_edition(self): """ updates user's relationships to a book """ work = models.Work.objects.create(title="test work")