Ejemplo n.º 1
0
def test_string_general():
    sl = builtin.string({'max-len': 2})
    assert sl('key', {
        'fo': 'b',
        'e': 'fb',
        'a': True,
        'b': 1111111111,
        'c': 1.23456789
    }) is None
Ejemplo n.º 2
0
def test_string_single_keys():
    sl = builtin.string({'keys': 'whee', 'required': False})
    assert sl(
        'key', {
            'fo': 'b',
            'e': 'fb',
            'whee': 'whooooooooooooo',
            'a': True,
            'b': 1111111111,
            'c': 1.23456789
        }) is None
Ejemplo n.º 3
0
def test_string_multiple_keys_max_len():
    sl = builtin.string({'keys': ['whee', 'whoo', 'whoa'], 'max-len': 9})
    # missing whoo key
    assert sl(
        'key', {
            'fo': 'b',
            'e': 'fb',
            'whee': 'whoo',
            'a': True,
            'b': 1111111111,
            'whoa': 'free mind',
            'c': 1.23456789
        }) is None
Ejemplo n.º 4
0
def test_string_multiple_keys_required():
    sl = builtin.string({'keys': ['whee', 'whoo', 'whoa'], 'required': True})
    assert sl(
        'key',
        {
            'fo': 'b',
            'e': 'fb',
            'whee':
            None,  # test that none is allowed as a value, even w/ required
            'a': True,
            'whoo': 'whoopty doo',
            'b': 1111111111,
            'whoa': 'free mind',
            'c': 1.23456789
        }) is None
Ejemplo n.º 5
0
def _string_validate_fail(cfg, meta, expected):
    assert builtin.string(cfg)('key', meta) == expected
Ejemplo n.º 6
0
def _string_fail_construct(d, expected):
    with raises(Exception) as got:
        builtin.string(d)
    assert_exception_correct(got.value, expected)