test_media_resource_field.py 文件源码

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

项目:km-api 作者: knowmetools 项目源码 文件源码
def test_to_internal_value_non_existent(km_user_factory):
    """
    If there is no media resource matching the provided ID, a
    ``ValidationError`` should be raised.
    """
    with mock.patch(
            'know_me.serializers.fields.MediaResourceField.context',
            new_callable=mock.PropertyMock) as mock_context:
        mock_context.return_value = {
            'km_user': km_user_factory(),
        }

        field = fields.MediaResourceField()

        with pytest.raises(ValidationError):
            field.to_internal_value(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号