You must now use 'eval' to get the body of a concept
This commit is contained in:
@@ -9,7 +9,7 @@ from core.sheerka import Sheerka, ExecutionContext
|
||||
from evaluators.MutipleSameSuccessEvaluator import MultipleSameSuccessEvaluator
|
||||
from parsers.ConceptLexerParser import Sequence, ZeroOrMore, StrMatch, OrderedChoice, Optional, ConceptMatch, \
|
||||
ConceptLexerParser
|
||||
from sdp.sheerkaDataProvider import SheerkaDataProvider
|
||||
from sdp.sheerkaDataProvider import SheerkaDataProvider, Event
|
||||
|
||||
tests_root = path.abspath("../build/tests")
|
||||
root_folder = "init_folder"
|
||||
@@ -39,7 +39,7 @@ def get_sheerka(use_dict=True, skip_builtins_in_db=True):
|
||||
|
||||
|
||||
def get_context(sheerka):
|
||||
return ExecutionContext("test", "xxx", sheerka)
|
||||
return ExecutionContext("test", Event(), sheerka)
|
||||
|
||||
|
||||
def get_default_concept():
|
||||
@@ -79,7 +79,7 @@ def test_i_can_eval_concept_with_python_body():
|
||||
res = sheerka.evaluate_user_input(text)
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].value == 1
|
||||
assert res[0].value == Concept(name="one", body=1).init_key() # by default, the concept is returned
|
||||
|
||||
|
||||
def test_i_can_eval_concept_with_concept_body():
|
||||
@@ -93,7 +93,7 @@ def test_i_can_eval_concept_with_concept_body():
|
||||
return_value = res[0].value
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert sheerka.isinstance(return_value, concept_one)
|
||||
assert return_value == Concept(name="un", body=Concept(name="one").init_key()).init_key()
|
||||
|
||||
|
||||
def test_i_can_eval_concept_with_no_body():
|
||||
@@ -207,23 +207,6 @@ as:
|
||||
assert sheerka.isinstance(res[0].value, BuiltinConcepts.CONCEPT_ALREADY_DEFINED)
|
||||
|
||||
|
||||
# def test_i_can_disable_an_evaluator():
|
||||
# sheerka = get_sheerka()
|
||||
# concept = Concept(name="one", body="1")
|
||||
# sheerka.add_in_cache(concept)
|
||||
#
|
||||
# text = "one"
|
||||
# p = next(e for e in sheerka.evaluators if e.__name__ == "PythonEvaluator")
|
||||
# p.enabled = False # not that you disable the class, not the instance
|
||||
#
|
||||
# res = sheerka.evaluate_user_input(text)
|
||||
# assert len(res) == 1
|
||||
# assert res[0].status
|
||||
# assert sheerka.isinstance(res[0].value, BuiltinConcepts.PARSER_RESULT)
|
||||
#
|
||||
# p.enabled = True # put back for the remaining unit tests
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text", [
|
||||
"",
|
||||
" ",
|
||||
@@ -293,9 +276,9 @@ def test_i_cannot_manage_duplicate_concepts_when_the_values_are_different():
|
||||
|
||||
concepts = res[0].value.body
|
||||
assert len(concepts) == 2
|
||||
sorted_values = sorted(concepts, key=lambda x: x.value)
|
||||
assert sorted_values[0].value == "hello another value"
|
||||
assert sorted_values[1].value == "hello foo"
|
||||
sorted_values = sorted(concepts, key=lambda x: x.value.body)
|
||||
assert sorted_values[0].value.body == "hello another value"
|
||||
assert sorted_values[1].value.body == "hello foo"
|
||||
|
||||
|
||||
def test_i_can_manage_concepts_with_the_same_key_when_values_are_the_same():
|
||||
@@ -308,7 +291,7 @@ def test_i_can_manage_concepts_with_the_same_key_when_values_are_the_same():
|
||||
res = sheerka.evaluate_user_input("hello 'foo'")
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].value == "hello foo"
|
||||
assert res[0].value.body == "hello foo" # I don't know yet the one to choose
|
||||
assert res[0].who == sheerka.get_evaluator_name(MultipleSameSuccessEvaluator.NAME)
|
||||
|
||||
|
||||
@@ -321,7 +304,7 @@ def test_i_can_create_concepts_with_python_code_as_body():
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert isinstance(res[0].value, list)
|
||||
assert isinstance(res[0].value.body, list)
|
||||
|
||||
|
||||
def test_i_can_create_concept_with_bnf_definition():
|
||||
|
||||
Reference in New Issue
Block a user