mirror of
https://github.com/jointakahe/takahe.git
synced 2024-12-29 00:20:29 +00:00
4ad4f468a4
Also suppress using external <a> tags for now, until we can separate them from hashtags properly.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import pytest
|
|
|
|
from activities.models import Post
|
|
from activities.services import PostService
|
|
from users.models import Identity
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_post_context(identity: Identity, config_system):
|
|
"""
|
|
Tests that post context fetching works correctly
|
|
"""
|
|
post1 = Post.create_local(
|
|
author=identity,
|
|
content="<p>first</p>",
|
|
visibility=Post.Visibilities.public,
|
|
)
|
|
post2 = Post.create_local(
|
|
author=identity,
|
|
content="<p>second</p>",
|
|
visibility=Post.Visibilities.public,
|
|
reply_to=post1,
|
|
)
|
|
post3 = Post.create_local(
|
|
author=identity,
|
|
content="<p>third</p>",
|
|
visibility=Post.Visibilities.public,
|
|
reply_to=post2,
|
|
)
|
|
# Test the view from the start of thread
|
|
ancestors, descendants = PostService(post1).context(None)
|
|
assert ancestors == []
|
|
assert descendants == [post2, post3]
|
|
# Test the view from the end of thread
|
|
ancestors, descendants = PostService(post3).context(None)
|
|
assert ancestors == [post2, post1]
|
|
assert descendants == []
|