Beispiel #1
0
def test_KnowledgeEngine_reset_declare_initialfact():
    from experta.engine import KnowledgeEngine

    ke = KnowledgeEngine()
    ke.reset()

    assert len(ke.facts) == 1
Beispiel #2
0
def test_KnowledgeEngine_reset_resets_facts():
    from experta.engine import KnowledgeEngine
    ke = KnowledgeEngine()
    ke.facts = None

    ke.reset()
    assert ke.facts is not None
Beispiel #3
0
def test_KnowledgeEngine_reset_resets_agenda():
    from experta.engine import KnowledgeEngine
    ke = KnowledgeEngine()
    ke.agenda = None

    ke.reset()
    assert ke.agenda is not None
Beispiel #4
0
def test_double_underscore_raise_on_declare():
    ke = KnowledgeEngine()
    ke.reset()

    ke.declare(Fact(__startwithdoubleunderscore__=True))

    with pytest.raises(KeyError):
        ke.declare(Fact(key__with__double__underscores=True))
Beispiel #5
0
def test_fact_setitem_do_raise_after_declare():
    f = Fact()
    ke = KnowledgeEngine()
    ke.reset()
    ke.declare(f)

    with pytest.raises(RuntimeError):
        f[0] = 1