def test_setitem_raise_on_invalid_value(patch_schema): patch_schema({'key': {'type': 'integer'}}) context = Context({}) with pytest.raises(DataError): context['key'] = 'invalid' assert 'key' not in context assert context.get('key') is None
def test_getitem(patch_schema): patch_schema({'key': {'type': 'string'}}) context = Context({'key': 'value'}) assert context['key'] == 'value' assert context.get('key') == 'value'
def test_get_should_return_default_if_dataerror(patch_schema): patch_schema({'key': {'type': 'integer'}}) context = Context({'key': 'invalid'}) assert context.get('key') is None
def test_get_should_return_default_if_key_is_missing(patch_schema): patch_schema({'key': {'type': 'integer'}}) context = Context({}) assert context.get('key') is None