Ejemplo n.º 1
0
def test_iter_validation_returns_iter_with_each_validationerror():
    schema_dict = {
        'type': 'array',
        'items': {'enum': [1, 2, 3]},
        'maxItems': 2,
    }
    data_dict = [2, 3, 4]
    expected_errors_validators = ('maxItems', 'enum')
    schema = Profile(schema_dict)
    errors = [error for error in schema.iter_errors(data_dict)]
    assert len(errors) == 2
    for error in errors:
        assert error.validator in expected_errors_validators
Ejemplo n.º 2
0
def test_iter_validation_returns_iter_with_each_validationerror():
    schema_dict = {
        'type': 'array',
        'items': {'enum': [1, 2, 3]},
        'maxItems': 2,
    }
    data_dict = [2, 3, 4]
    expected_errors_validators = ('maxItems', 'enum')
    schema = Profile(schema_dict)
    errors = [error for error in schema.iter_errors(data_dict)]
    assert len(errors) == 2
    for error in errors:
        assert error.validator in expected_errors_validators
Ejemplo n.º 3
0
def test_iter_validation_returns_no_errors_if_data_is_valid():
    schema_dict = {}
    data_dict = ''
    schema = Profile(schema_dict)
    errors = [error for error in schema.iter_errors(data_dict)]
    assert len(errors) == 0
Ejemplo n.º 4
0
def test_iter_validation_returns_no_errors_if_data_is_valid():
    schema_dict = {}
    data_dict = ''
    schema = Profile(schema_dict)
    errors = [error for error in schema.iter_errors(data_dict)]
    assert len(errors) == 0