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)
评论列表
文章目录