test_media_resource_field.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:km-api 作者: knowmetools 项目源码 文件源码
def test_to_representation(media_resource_factory, serializer_context):
    """
    ``.to_representation()`` should return the serialized version of the
    provided media resource.
    """
    resource = media_resource_factory()
    serializer = MediaResourceSerializer(resource, context=serializer_context)

    with mock.patch(
            'know_me.serializers.fields.MediaResourceField.context',
            new_callable=mock.PropertyMock) as mock_context:
        mock_context.return_value = serializer_context

        field = fields.MediaResourceField()

        assert field.to_representation(resource) == serializer.data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号