031bd0274e
Fixed #44 : BnfNodeParser: I must simplify results when multiple levels of ISA Fixed #45 : Dynamic variables cannot be parsed at restart Fixed #46 : Concepts variables values are transformed into list by default Fixed #47 : SheerkaAdmin. Add min, max, mean time when restoring files
144 lines
3.9 KiB
Python
144 lines
3.9 KiB
Python
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
|
|
|
|
|
class TestSheerkaNonRegDisplay(TestUsingMemoryBasedSheerka):
|
|
|
|
def test_i_can_display_results_when_return_values_processing_is_on(self, capsys):
|
|
init = [
|
|
"def concept one as 1",
|
|
]
|
|
|
|
sheerka = self.init_scenario(init)
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("one")
|
|
|
|
captured = capsys.readouterr()
|
|
assert captured.out == "ReturnValue(who=evaluators.OneSuccess, status=True, value=(1001)one)\n"
|
|
|
|
def test_i_can_display_multiple_concepts_description(self, capsys):
|
|
init = [
|
|
"def concept foo as 1",
|
|
"def concept foo as 2",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
capsys.readouterr()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("desc(foo)")
|
|
|
|
captured = capsys.readouterr()
|
|
assert captured.out == """id : 1001
|
|
name : foo
|
|
key : foo
|
|
definition: None
|
|
type : None
|
|
hash : 16f7fbb8bc509b8c652edaf3d0c0457d15a37f0a862fbe03fa357b0c77249c46
|
|
body : 1
|
|
where : None
|
|
pre : None
|
|
post : None
|
|
ret : None
|
|
vars : []
|
|
props : {}
|
|
id : 1002
|
|
name : foo
|
|
key : foo
|
|
definition: None
|
|
type : None
|
|
hash : 7036cd5ffa9294d2e1dc9bf9c9bbe2783ace5cf7f423bfce9b28c8d33c0d1d0c
|
|
body : 2
|
|
where : None
|
|
pre : None
|
|
post : None
|
|
ret : None
|
|
vars : []
|
|
props : {}
|
|
"""
|
|
|
|
def test_i_can_describe_a_rule(self, capsys):
|
|
sheerka = self.get_sheerka()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("desc(r:|1:)")
|
|
captured = capsys.readouterr()
|
|
|
|
assert captured.out == """id : 1
|
|
name : Print return values
|
|
type : print
|
|
predicate: __rets
|
|
action : list(__rets)
|
|
priority : 4
|
|
compiled : True
|
|
enabled : True
|
|
"""
|
|
|
|
def test_i_can_display_multiple_success(self, capsys):
|
|
init = [
|
|
"def concept foo as 1",
|
|
"def concept foo as 2",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
capsys.readouterr()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("foo")
|
|
|
|
captured = capsys.readouterr()
|
|
assert captured.out == """ReturnValue(who=evaluators.Concept, status=True, value=(1001)foo)
|
|
ReturnValue(who=evaluators.Concept, status=True, value=(1002)foo)
|
|
"""
|
|
|
|
def test_i_can_list_ontologies(self, capsys):
|
|
init = [
|
|
"push_ontology('test 1')",
|
|
"push_ontology('test 2')",
|
|
"pop_ontology()",
|
|
"push_ontology('test 3')",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
capsys.readouterr()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("ontologies()")
|
|
|
|
captured = capsys.readouterr()
|
|
assert captured.out == """test 3
|
|
test 1
|
|
#unit_test#
|
|
__default__
|
|
"""
|
|
|
|
def test_i_can_display_objects_in_memory(self, capsys):
|
|
init = [
|
|
"def concept one as 1",
|
|
"def concept two as 2",
|
|
"one",
|
|
"two"
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
capsys.readouterr()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
sheerka.evaluate_user_input("in_memory()")
|
|
captured = capsys.readouterr()
|
|
assert captured.out == """one: (1001)one
|
|
two: (1002)two
|
|
"""
|
|
|
|
def test_i_can_retrieve_history(self, capsys):
|
|
init = [
|
|
"test()",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
capsys.readouterr()
|
|
|
|
sheerka.enable_process_return_values = True
|
|
res = sheerka.evaluate_user_input(f"history()")
|
|
|
|
assert len(res) == 1
|
|
assert res[0].status
|
|
|
|
captured = capsys.readouterr()
|
|
assert " : test()" in captured.out
|
|
assert " : history()" in captured.out
|