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+']
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"']
def test_validate_simple_equality(): jexl = JEXL() errors = list(jexl.validate('FOO_BAR ==12345')) assert errors == []