Adds test for reading status with comment
This commit is contained in:
parent
75e69eb269
commit
d2f80c2446
@ -58,6 +58,9 @@ class ReadingViews(TestCase):
|
|||||||
"post-status": True,
|
"post-status": True,
|
||||||
"privacy": "followers",
|
"privacy": "followers",
|
||||||
"start_date": "2020-01-05",
|
"start_date": "2020-01-05",
|
||||||
|
"book": self.book.id,
|
||||||
|
"mention_books": self.book.id,
|
||||||
|
"user": self.local_user.id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
@ -77,6 +80,45 @@ class ReadingViews(TestCase):
|
|||||||
self.assertEqual(readthrough.user, self.local_user)
|
self.assertEqual(readthrough.user, self.local_user)
|
||||||
self.assertEqual(readthrough.book, self.book)
|
self.assertEqual(readthrough.book, self.book)
|
||||||
|
|
||||||
|
def test_start_reading_with_comment(self, *_):
|
||||||
|
"""begin a book"""
|
||||||
|
shelf = self.local_user.shelf_set.get(identifier=models.Shelf.READING)
|
||||||
|
self.assertFalse(shelf.books.exists())
|
||||||
|
self.assertFalse(models.Status.objects.exists())
|
||||||
|
|
||||||
|
request = self.factory.post(
|
||||||
|
"",
|
||||||
|
{
|
||||||
|
"post-status": True,
|
||||||
|
"privacy": "followers",
|
||||||
|
"start_date": "2020-01-05",
|
||||||
|
"content": "hello hello",
|
||||||
|
"book": self.book.id,
|
||||||
|
"mention_books": self.book.id,
|
||||||
|
"user": self.local_user.id,
|
||||||
|
"reading_status": "reading",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
request.user = self.local_user
|
||||||
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
views.ReadingStatus.as_view()(request, "start", self.book.id)
|
||||||
|
|
||||||
|
self.assertEqual(shelf.books.get(), self.book)
|
||||||
|
|
||||||
|
status = models.Comment.objects.get()
|
||||||
|
self.assertEqual(status.user, self.local_user)
|
||||||
|
self.assertEqual(status.book, self.book)
|
||||||
|
self.assertFalse(status.mention_books.exists())
|
||||||
|
self.assertEqual(status.privacy, "followers")
|
||||||
|
self.assertEqual(status.content, "<p>hello hello</p>")
|
||||||
|
self.assertEqual(status.reading_status, "reading")
|
||||||
|
|
||||||
|
readthrough = models.ReadThrough.objects.get()
|
||||||
|
self.assertIsNotNone(readthrough.start_date)
|
||||||
|
self.assertIsNone(readthrough.finish_date)
|
||||||
|
self.assertEqual(readthrough.user, self.local_user)
|
||||||
|
self.assertEqual(readthrough.book, self.book)
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.remove_book_statuses_task.delay")
|
@patch("bookwyrm.activitystreams.remove_book_statuses_task.delay")
|
||||||
def test_start_reading_reshelve(self, *_):
|
def test_start_reading_reshelve(self, *_):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user