Esempio n. 1
0
def test_validate():
    jexl = JEXL()
    jexl.add_transform('foo', lambda x: x + 1)
    assert list(jexl.validate('5+6|foo')) == []

    errors = list(jexl.validate('5+6|bar'))
    assert len(errors) == 1
    assert 'bar' in errors[0]

    errors = list(jexl.validate('1+'))
    assert errors == ['Could not parse expression: 1+']
Esempio n. 2
0
def test_validate():
    jexl = JEXL()
    jexl.add_transform('foo', lambda x: x + 1)
    assert list(jexl.validate('5+6|foo')) == []

    errors = list(jexl.validate('5+6|bar'))
    assert len(errors) == 1
    assert 'bar' in errors[0]

    errors = list(jexl.validate('1+'))
    assert errors == ['Could not parse expression: 1+']

    errors = list(jexl.validate('"\n"'))
    assert errors == ['Could not parse expression: "\n"']
Esempio n. 3
0
def test_validate_simple_equality():
    jexl = JEXL()
    errors = list(jexl.validate('FOO_BAR ==12345'))
    assert errors == []