def test_shopping_cart_first_item():
    validation_rules1 = (
        ('items', gl.type_(list),
         ('@first',
          ('price', gl.eq(1.34)))))
    result = gl.validate(validation_rules1, valid_test_data)
    assert result.success is True
Ejemplo n.º 2
0
comparison_validators_test_data = [
    {
        'validator': gl.lt(5),
        'valid': [1, 2, 3, 4],
        'invalid': [5, 6, 7, 8, 9, 10],
        'error': 'is not less than'
    },
    {
        'validator': gl.gt(5),
        'valid': [6, 7, 8, 9, 10],
        'invalid': [1, 2, 3, 4, 5],
        'error': 'is not greater than'
    },
    {
        'validator': gl.eq(5),
        'valid': [5],
        'invalid': [1, 2, 3, 4, 6, 7, 8, 9, 10],
        'error': 'is not equal to'
    },
    {
        'validator': gl.ne(5),
        'valid': [1, 2, 3, 4, 6, 7, 8, 9, 10],
        'invalid': [5],
        'error': 'is equal to'
    },
    {
        'validator': gl.lte(5),
        'valid': [1, 2, 3, 4, 5],
        'invalid': [6, 7, 8, 9, 10],
        'error': 'is not less or equal to'