class Test(KnowledgeEngine): @Rule(InitialFact()) def rule1(self): pass @Rule(InitialFact()) def rule2(self): pass
def test_prepare_rule__or_starting_with_not(): from pyknow import Rule, InitialFact, NOT, Fact, OR, AND rule = Rule(OR(NOT(Fact(1)), NOT(Fact(2))))(lambda: None) assert list(utils.prepare_rule(rule)) == [ OR(AND(InitialFact(), NOT(Fact(1))), AND(InitialFact(), NOT(Fact(2)))) ]
def test_KnowledgeEngine_has_initialfacts(): from pyknow.engine import KnowledgeEngine from pyknow import InitialFact assert list(KnowledgeEngine()._declare_initial_fact()) == [InitialFact()]
def test_prepare_rule__rule_starting_with_not(): from pyknow import Rule, InitialFact, NOT, Fact rule = Rule(NOT(Fact(1)))(lambda: None) assert list(utils.prepare_rule(rule)) == [InitialFact(), NOT(Fact(1))]
def test_prepare_rule_empty(): from pyknow import Rule, InitialFact rule = Rule()(lambda: None) assert list(utils.prepare_rule(rule)) == [InitialFact()]