Exemple #1
0
def test_parse_value_string():
    with assert_raises(InvalidValue):
        parse_value_string(Type('bool[]'), '1')

    with assert_raises(InvalidValue):
        parse_value_string(Type('bool[2]'), '[1]')
    with assert_raises(InvalidValue):
        parse_value_string(Type('bool[<=1]'), '[1, 0]')

    with assert_raises(InvalidValue):
        parse_value_string(Type('bool[]'), '[2]')

    value = parse_value_string(Type('bool[]'), '[1]')
    assert value
Exemple #2
0
def test_parse_value_string_not_implemented():
    with pytest.raises(NotImplementedError):
        parse_value_string(Type('pkg/Foo[]'), '')
Exemple #3
0
def test_parse_value_string():
    with pytest.raises(InvalidValue):
        parse_value_string(Type('bool[]'), '1')

    with pytest.raises(InvalidValue):
        parse_value_string(Type('bool[2]'), '[1]')
    with pytest.raises(InvalidValue):
        parse_value_string(Type('bool[<=1]'), '[1, 0]')

    with pytest.raises(InvalidValue):
        parse_value_string(Type('bool[]'), '[2]')

    value = parse_value_string(Type('bool[]'), '[1]')
    assert value

    value = parse_value_string(Type('string[]'), "['foo', 'bar']")
    assert value == ['foo', 'bar']

    with pytest.raises(InvalidValue):
        parse_value_string(Type('string[<=2]'), '[foo, bar, baz]')

    with pytest.raises(InvalidValue):
        parse_value_string(Type('string[<=2]'), """["foo", 'ba"r', "ba,z"]""")

    with pytest.raises(ValueError):
        parse_value_string(Type('string[<=3]'), """[,"foo", 'ba"r', "ba,z"]""")

    with pytest.raises(ValueError):
        parse_value_string(Type('string[<=3]'), """["foo", ,'ba"r', "ba,z"]""")

    parse_value_string(Type('string[<=2]'), """["fo'o\\\", bar", baz]""")
    assert value
Exemple #4
0
def test_parse_value_string_primitive():
    parse_value_string(Type('bool'), '1')
Exemple #5
0
def test_parse_value_string_not_implemented():
    with assert_raises(NotImplementedError):
        parse_value_string(Type('string[]'), '[foo, bar]')

    with assert_raises(NotImplementedError):
        parse_value_string(Type('pkg/Foo[]'), '')
def test_parse_value_string_primitive():
    parse_value_string(Type('bool'), '1')