2022-12-18 16:09:25 +00:00
import pytest
from activities . models import Post
from activities . models . post_types import QuestionData
from core . ld import canonicalise
@pytest.mark.django_db
2022-12-20 11:39:45 +00:00
def test_question_post ( config_system , identity , remote_identity , httpx_mock ) :
2022-12-18 16:09:25 +00:00
data = {
" cc " : [ ] ,
2022-12-20 11:39:45 +00:00
" id " : " https://remote.test/test-actor/statuses/109519951621804608/activity " ,
2022-12-18 16:09:25 +00:00
" to " : identity . absolute_profile_uri ( ) ,
" type " : " Create " ,
2022-12-20 11:39:45 +00:00
" actor " : " https://remote.test/test-actor/ " ,
2022-12-18 16:09:25 +00:00
" object " : {
" cc " : [ ] ,
2022-12-20 11:39:45 +00:00
" id " : " https://remote.test/test-actor/statuses/109519951621804608 " ,
2022-12-18 16:09:25 +00:00
" to " : identity . absolute_profile_uri ( ) ,
" tag " : [ ] ,
2022-12-20 11:39:45 +00:00
" url " : " https://remote.test/test-actor/109519951621804608 " ,
2022-12-18 16:09:25 +00:00
" type " : " Question " ,
" oneOf " : [
{
" name " : " Option 1 " ,
" type " : " Note " ,
" replies " : { " type " : " Collection " , " totalItems " : 0 } ,
} ,
{
" name " : " Option 2 " ,
" type " : " Note " ,
" replies " : { " type " : " Collection " , " totalItems " : 0 } ,
} ,
] ,
" content " : ' <p>This is a poll :python: </p><p><span class= " h-card " ><a href= " https://ehakat.manfre.net/@mike/ " class= " u-url mention " >@<span>mike</span></a></span></p> ' ,
" endTime " : " 2022-12-18T22:03:59Z " ,
" replies " : {
2022-12-20 11:39:45 +00:00
" id " : " https://remote.test/test-actor/statuses/109519951621804608/replies " ,
2022-12-18 16:09:25 +00:00
" type " : " Collection " ,
" first " : {
2022-12-20 11:39:45 +00:00
" next " : " https://remote.test/test-actor/109519951621804608/replies?only_other_accounts=true&page=true " ,
2022-12-18 16:09:25 +00:00
" type " : " CollectionPage " ,
" items " : [ ] ,
2022-12-20 11:39:45 +00:00
" partOf " : " https://remote.test/test-actor/109519951621804608/replies " ,
2022-12-18 16:09:25 +00:00
} ,
} ,
" published " : " 2022-12-15T22:03:59Z " ,
" attachment " : [ ] ,
" contentMap " : {
" en " : ' <p>This is a poll :python: </p><p><span class= " h-card " ><a href= " https://ehakat.manfre.net/@mike/ " class= " u-url mention " >@<span>mike</span></a></span></p> '
} ,
" as:sensitive " : False ,
2022-12-20 11:39:45 +00:00
" attributedTo " : " https://remote.test/test-actor/ " ,
" toot:votersCount " : 0 ,
2022-12-18 16:09:25 +00:00
} ,
" published " : " 2022-12-15T22:03:59Z " ,
}
post = Post . by_ap (
data = canonicalise ( data [ " object " ] , include_security = True ) , create = True
)
assert post . type == Post . Types . question
QuestionData . parse_obj ( post . type_data )