Example #1
0
 def test_validation_rejects_empty_tuple(s):
     p = vld.ObjectTypeProcessor()
     value = ()
     with pytest.raises(err.ValidationError) as e:
         rv = p.run(value, None)
     assert 'wrong data type' in e.value.args[0].lower()
     assert 'got "tuple"' in e.value.args[0].lower()
Example #2
0
 def test_validation_rejects_strings(s):
     p = vld.ObjectTypeProcessor()
     value = 'abcdelf'
     with pytest.raises(err.ValidationError) as e:
         rv = p.run(value, None)
     assert 'wrong data type' in e.value.args[0].lower()
     assert 'got "str"' in e.value.args[0].lower()
Example #3
0
 def test_validation_rejects_list_type(s):
     p = vld.ObjectTypeProcessor()
     value = ['a', 23, 'b', 12]
     with pytest.raises(err.ValidationError) as e:
         rv = p.run(value, None)
     assert 'wrong data type' in e.value.args[0].lower()
     assert 'got "list"' in e.value.args[0].lower()
Example #4
0
 def test_validation_rv_is_not_original_object(s):
     p = vld.ObjectTypeProcessor()
     value = {'a': 23, 'b': 12}
     rv = p.run(value, None)
     assert rv is not value
     value = {}
     rv = p.run(value, None)
     assert rv is not value
Example #5
0
 def test_validation_rejects_list_of_tuples(s):
     p = vld.ObjectTypeProcessor()
     value = (('a', 23), ('b', 12))
     with pytest.raises(err.ValidationError) as e:
         rv = p.run(value, None)
     error = e.value
     assert 'wrong data type' in e.value.args[0].lower()
     assert 'got "tuple"' in e.value.args[0].lower()
Example #6
0
 def test_validation_rv_has_same_values(s):
     p = vld.ObjectTypeProcessor()
     value = {'a': 23, 'b': 12}
     rv = p.run(value, None)
     assert rv == value
Example #7
0
 def test_validation_rv_of_null_object_is_null_by_default(s):
     p = vld.ObjectTypeProcessor()
     rv = p.run(None, None)
     assert rv is None
Example #8
0
 def test_validation_rv_of_empty_object_is_empty_obj(s):
     p = vld.ObjectTypeProcessor()
     rv = p.run({}, None)
     assert rv == {}