Fixed Syntax validation and autocompletion. Fixed unit tests
This commit is contained in:
@@ -4,7 +4,8 @@ Tests for the FormulaEngine facade.
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from myfasthtml.core.formula.dsl.exceptions import FormulaSyntaxError, FormulaCycleError
|
||||
from myfasthtml.core.dsl.exceptions import DSLSyntaxError
|
||||
from myfasthtml.core.formula.dsl.exceptions import FormulaCycleError
|
||||
from myfasthtml.core.formula.engine import FormulaEngine
|
||||
|
||||
|
||||
@@ -72,9 +73,9 @@ class TestSetFormula:
|
||||
assert totals[2] == 50
|
||||
|
||||
def test_i_cannot_set_invalid_formula(self):
|
||||
"""Test that invalid formula syntax raises FormulaSyntaxError."""
|
||||
"""Test that invalid formula syntax raises DSLSyntaxError."""
|
||||
engine = make_engine()
|
||||
with pytest.raises(FormulaSyntaxError):
|
||||
with pytest.raises(DSLSyntaxError):
|
||||
engine.set_formula("t", "col", "{Price} * * {Qty}")
|
||||
|
||||
def test_i_cannot_set_formula_with_cycle(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ from myfasthtml.core.formula.dataclasses import (
|
||||
LiteralNode,
|
||||
FormulaDefinition,
|
||||
)
|
||||
from myfasthtml.core.formula.dsl.exceptions import FormulaSyntaxError
|
||||
from myfasthtml.core.dsl.exceptions import DSLSyntaxError
|
||||
from myfasthtml.core.formula.engine import parse_formula
|
||||
|
||||
|
||||
@@ -177,12 +177,12 @@ def test_i_can_parse_nested_functions():
|
||||
"123 + + 456", # double operator
|
||||
])
|
||||
def test_i_cannot_parse_invalid_syntax(formula_text):
|
||||
"""Test that invalid syntax raises FormulaSyntaxError."""
|
||||
with pytest.raises(FormulaSyntaxError):
|
||||
"""Test that invalid syntax raises DSLSyntaxError."""
|
||||
with pytest.raises(DSLSyntaxError):
|
||||
parse_formula(formula_text)
|
||||
|
||||
|
||||
def test_i_cannot_parse_unclosed_brace():
|
||||
"""Test that an unclosed brace raises FormulaSyntaxError."""
|
||||
with pytest.raises(FormulaSyntaxError):
|
||||
"""Test that an unclosed brace raises DSLSyntaxError."""
|
||||
with pytest.raises(DSLSyntaxError):
|
||||
parse_formula("{Price")
|
||||
|
||||
Reference in New Issue
Block a user