32 lines
854 B
Python
32 lines
854 B
Python
from sheerkarete.common import ReteToken, WME, V
|
|
from sheerkarete.conditions import Condition, NegatedConjunctiveConditions
|
|
|
|
|
|
def test_token():
|
|
tdummy = ReteToken(None, None)
|
|
t0 = ReteToken(tdummy, WME('B1', 'on', 'B2'))
|
|
|
|
assert tdummy.parent is None
|
|
assert t0.parent == tdummy
|
|
|
|
assert tdummy.children == [t0]
|
|
assert t0.children == []
|
|
|
|
|
|
def test_condition_vars():
|
|
c0 = Condition(V('x'), 'is', V('y'))
|
|
assert c0.vars == [('identifier', V("x")), ('value', V("y"))]
|
|
|
|
|
|
def test_condition_contain():
|
|
c0 = Condition(V('a'), V('b'), V('c'))
|
|
assert c0.contain(V('a'))
|
|
assert not c0.contain(V('d'))
|
|
|
|
|
|
def test_ncc():
|
|
c0 = Condition(V('a'), V('b'), V('c'))
|
|
c1 = NegatedConjunctiveConditions(Condition(V('x'), 'color', 'red'))
|
|
c2 = NegatedConjunctiveConditions(c0, c1)
|
|
assert c2.number_of_conditions == 2
|