def test_anyof_allof_schema_validate(): # make sure schema with 'anyof' and 'allof' constraints are checked # correctly schema = { 'doc': { 'type': 'dict', 'anyof': [{ 'schema': [{ 'param': { 'type': 'number' } }] }] } } assert_schema_error({'doc': 'this is my document'}, schema) schema = { 'doc': { 'type': 'dict', 'allof': [{ 'schema': [{ 'param': { 'type': 'number' } }] }] } } assert_schema_error({'doc': 'this is my document'}, schema)
def test_rules_set_with_dict_field(): document = {'a_dict': {'foo': 1}} schema = {'a_dict': {'type': 'dict', 'schema': {'foo': 'rule'}}} # the schema's not yet added to the valid ones, so test the faulty first rules_set_registry.add('rule', {'tüpe': 'integer'}) assert_schema_error(document, schema) rules_set_registry.add('rule', {'type': 'integer'}) assert_success(document, schema)
def test_anyof_allof_schema_validate(): # make sure schema with 'anyof' and 'allof' constraints are checked # correctly schema = { 'doc': {'type': 'dict', 'anyof': [{'schema': [{'param': {'type': 'number'}}]}]} } assert_schema_error({'doc': 'this is my document'}, schema) schema = { 'doc': {'type': 'dict', 'allof': [{'schema': [{'param': {'type': 'number'}}]}]} } assert_schema_error({'doc': 'this is my document'}, schema)
def bad_of_rules(): schema = {'foo': {'anyof': {'type': 'string'}}} assert_schema_error({}, schema)
def test_normalization_rules_are_invalid_in_of_rules(): schema = {0: {'anyof': [{'coerce': lambda x: x}]}} assert_schema_error({}, schema)
def test_bad_of_rules(): schema = {'foo': {'anyof': {'type': 'string'}}} assert_schema_error({}, schema)