Adds tests of creating book with author
This commit is contained in:
parent
58b48faff8
commit
37e29cc735
|
@ -169,6 +169,23 @@ class BookViews(TestCase):
|
||||||
book = models.Edition.objects.get(title="New Title")
|
book = models.Edition.objects.get(title="New Title")
|
||||||
self.assertEqual(book.parent_work, self.work)
|
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):
|
def test_switch_edition(self):
|
||||||
""" 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")
|
||||||
|
|
Loading…
Reference in New Issue