forked from mirrors/bookwyrm
test coment
This commit is contained in:
parent
ea420f9889
commit
932b4abcfe
1 changed files with 56 additions and 0 deletions
56
fedireads/tests/test_comment.py
Normal file
56
fedireads/tests/test_comment.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from django.test import TestCase
|
||||
|
||||
from fedireads import models
|
||||
from fedireads import status as status_builder
|
||||
|
||||
|
||||
class Comment(TestCase):
|
||||
''' we have hecka ways to create statuses '''
|
||||
def setUp(self):
|
||||
self.user = models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
self.book = models.Edition.objects.create(title='Example Edition')
|
||||
|
||||
|
||||
def test_create_comment(self):
|
||||
comment = status_builder.create_comment(
|
||||
self.user, self.book, 'commentary')
|
||||
self.assertEqual(comment.content, 'commentary')
|
||||
|
||||
|
||||
def test_comment_from_activity(self):
|
||||
activity = {
|
||||
"id": "https://example.com/user/mouse/comment/6",
|
||||
"url": "https://example.com/user/mouse/comment/6",
|
||||
"inReplyTo": None,
|
||||
"published": "2020-05-08T23:45:44.768012+00:00",
|
||||
"attributedTo": "https://example.com/user/mouse",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://example.com/user/mouse/followers"
|
||||
],
|
||||
"sensitive": False,
|
||||
"content": "commentary",
|
||||
"type": "Note",
|
||||
"attachment": [],
|
||||
"replies": {
|
||||
"id": "https://example.com/user/mouse/comment/6/replies",
|
||||
"type": "Collection",
|
||||
"first": {
|
||||
"type": "CollectionPage",
|
||||
"next": "https://example.com/user/mouse/comment/6/replies?only_other_accounts=true&page=true",
|
||||
"partOf": "https://example.com/user/mouse/comment/6/replies",
|
||||
"items": []
|
||||
}
|
||||
},
|
||||
"inReplyToBook": self.book.absolute_id,
|
||||
"fedireadsType": "Comment"
|
||||
}
|
||||
comment = status_builder.create_comment_from_activity(
|
||||
self.user, activity)
|
||||
self.assertEqual(comment.content, 'commentary')
|
||||
self.assertEqual(comment.book, self.book)
|
||||
self.assertEqual(
|
||||
comment.published_date, '2020-05-08T23:45:44.768012+00:00')
|
Loading…
Reference in a new issue