Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
def bad_of_rules():
    schema = {'foo': {'anyof': {'type': 'string'}}}
    assert_schema_error({}, schema)
Exemplo n.º 5
0
def test_normalization_rules_are_invalid_in_of_rules():
    schema = {0: {'anyof': [{'coerce': lambda x: x}]}}
    assert_schema_error({}, schema)
Exemplo n.º 6
0
def test_normalization_rules_are_invalid_in_of_rules():
    schema = {0: {'anyof': [{'coerce': lambda x: x}]}}
    assert_schema_error({}, schema)
Exemplo n.º 7
0
def test_bad_of_rules():
    schema = {'foo': {'anyof': {'type': 'string'}}}
    assert_schema_error({}, schema)