2023-07-10 23:07:33 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
import printpub.post.models
|
|
|
|
import printpub.post.serializers.json
|
|
|
|
import printpub.user.models
|
|
|
|
|
|
|
|
|
2023-07-11 03:42:06 +00:00
|
|
|
def test_serializes_post(mock_domain):
|
2023-07-10 23:07:33 +00:00
|
|
|
poster = printpub.user.models.Poster()
|
|
|
|
poster.save()
|
|
|
|
user = printpub.user.models.LocalUser(
|
|
|
|
username="wint", password="hunter2", display_name="dril", poster=poster
|
|
|
|
)
|
|
|
|
user.save()
|
|
|
|
post = printpub.post.models.Post(
|
|
|
|
author=poster,
|
|
|
|
content='"im not owned! im not owned!!", i continue to insist as i slowly shrink and transform into a corn cob',
|
|
|
|
)
|
|
|
|
|
|
|
|
post_serializer = printpub.post.serializers.json.PostSerializer(post)
|
|
|
|
assert post_serializer.data == {
|
|
|
|
"content": '"im not owned! im not owned!!", i continue to insist as i slowly shrink and transform into a corn cob',
|
2023-07-11 03:42:06 +00:00
|
|
|
"author": {"display_name": "dril", "username": "wint", "domain": "my.website"},
|
2023-07-10 23:07:33 +00:00
|
|
|
}
|