2020-09-17 20:02:52 +00:00
|
|
|
import datetime
|
|
|
|
|
2021-05-26 21:57:29 +00:00
|
|
|
from unittest.mock import patch
|
2020-09-17 20:02:52 +00:00
|
|
|
from django.test import TestCase
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm import models
|
2020-09-17 20:02:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Author(TestCase):
|
|
|
|
def setUp(self):
|
2021-05-26 21:57:29 +00:00
|
|
|
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
|
|
|
|
self.book = models.Edition.objects.create(
|
|
|
|
title="Example Edition",
|
|
|
|
remote_id="https://example.com/book/1",
|
|
|
|
)
|
2020-09-17 20:02:52 +00:00
|
|
|
self.author = models.Author.objects.create(
|
2021-03-08 16:49:10 +00:00
|
|
|
name="Author fullname",
|
|
|
|
aliases=["One", "Two"],
|
|
|
|
bio="bio bio bio",
|
2020-09-17 20:02:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_serialize_model(self):
|
|
|
|
activity = self.author.to_activity()
|
2021-03-08 16:49:10 +00: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")
|