bookwyrm-mastodon/bookwyrm/tests/activitypub/test_author.py

28 lines
886 B
Python
Raw Normal View History

"""test author serializer"""
from django.test import TestCase
from bookwyrm import models
class Author(TestCase):
2022-04-08 17:24:14 -04:00
"""serialize author tests"""
2022-04-08 17:23:37 -04:00
def setUp(self):
2022-04-08 17:24:14 -04:00
"""initial data"""
2021-08-02 19:05:40 -04:00
self.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
)
self.author = models.Author.objects.create(
2021-03-08 11:49:10 -05:00
name="Author fullname",
aliases=["One", "Two"],
bio="bio bio bio",
)
def test_serialize_model(self):
2022-04-08 17:24:14 -04:00
"""check presense of author fields"""
activity = self.author.to_activity()
2021-03-08 11:49:10 -05:00
self.assertEqual(activity["id"], self.author.remote_id)
self.assertIsInstance(activity["aliases"], list)
self.assertEqual(activity["aliases"], ["One", "Two"])
self.assertEqual(activity["name"], "Author fullname")