Fixes review rating serialization

This commit is contained in:
Mouse Reeve 2021-04-29 15:16:51 -07:00
parent daf65e230d
commit d61ba2e474
2 changed files with 5 additions and 4 deletions

View file

@ -83,4 +83,5 @@ class Rating(Comment):
rating: int
content: str = None
name: str = None # not used, but the model inherits from Review
type: str = "Rating"

View file

@ -129,8 +129,8 @@ class InboxCreate(TestCase):
def test_create_rating(self):
"""a remote rating activity"""
models.Edition.objects.create(
title="Test Book", origin_id="https://example.com/book/1"
book = models.Edition.objects.create(
title="Test Book", remote_id="https://example.com/book/1"
)
activity = self.create_json
activity["object"] = {
@ -160,8 +160,8 @@ class InboxCreate(TestCase):
with patch("bookwyrm.activitystreams.ActivityStream.add_status") as redis_mock:
views.inbox.activity_task(activity)
self.assertTrue(redis_mock.called)
rating = models.Status.objects.select_subclasses().first()
self.assertEqual(rating.book, self.book)
rating = models.ReviewRating.objects.first()
self.assertEqual(rating.book, book)
self.assertEqual(rating.rating, 3.0)
def test_create_list(self):