示例#1
0
def test_api_full_actor_serializer(factories, to_api_date):
    summary = factories["common.Content"]()
    icon = factories["common.Attachment"]()
    user = factories["users.User"]()
    actor = user.create_actor(summary_obj=summary, attachment_icon=icon)
    expected = {
        "fid": actor.fid,
        "url": actor.url,
        "creation_date": to_api_date(actor.creation_date),
        "last_fetch_date": to_api_date(actor.last_fetch_date),
        "user": users_serializers.UserBasicSerializer(user).data,
        "is_channel": False,
        "domain": actor.domain_id,
        "type": actor.type,
        "manually_approves_followers": actor.manually_approves_followers,
        "full_username": actor.full_username,
        "name": actor.name,
        "preferred_username": actor.preferred_username,
        "is_local": actor.is_local,
        "summary": common_serializers.ContentSerializer(summary).data,
        "icon": common_serializers.AttachmentSerializer(icon).data,
    }

    serializer = api_serializers.FullActorSerializer(actor)

    assert serializer.data == expected
示例#2
0
def test_can_retrieve_actor(factories, api_client, preferences):
    preferences["common__api_authentication_required"] = False
    actor = factories["federation.Actor"]()
    url = reverse("api:v1:federation:actors-detail",
                  kwargs={"full_username": actor.full_username})
    response = api_client.get(url)

    expected = api_serializers.FullActorSerializer(actor).data
    assert response.data == expected