mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-05-19 00:38:21 +00:00
9d502f5ee2
Pylint's `bad-classmethod-argument` is disabled for each definition to avoid rewriting the method bodies just to rename `self` → `cls`. This can be done gradually, as the setUpTestData methods are modified along the way.
29 lines
955 B
Python
29 lines
955 B
Python
"""test author serializer"""
|
|
from django.test import TestCase
|
|
from bookwyrm import models
|
|
|
|
|
|
class Author(TestCase):
|
|
"""serialize author tests"""
|
|
|
|
@classmethod
|
|
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
|
|
"""initial data"""
|
|
self.book = models.Edition.objects.create(
|
|
title="Example Edition",
|
|
remote_id="https://example.com/book/1",
|
|
)
|
|
self.author = models.Author.objects.create(
|
|
name="Author fullname",
|
|
aliases=["One", "Two"],
|
|
bio="bio bio bio",
|
|
)
|
|
|
|
def test_serialize_model(self):
|
|
"""check presence of author fields"""
|
|
activity = self.author.to_activity()
|
|
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")
|