Fixed #20: I can parse simple concepts
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import pytest
|
||||
|
||||
from base import BaseTest
|
||||
from evaluators.PythonParser import PythonParser
|
||||
from evaluators.RecognizeDefConcept import RecognizeDefConcept
|
||||
from evaluators.RecognizeSimpleConcept import RecognizeSimpleConcept
|
||||
from evaluators.ResolvePythonVsSimpleConcept import ResolvePythonVsSimpleConcept
|
||||
from helpers import _rv, _rvf
|
||||
|
||||
|
||||
class TestResolvePythonVsSimpleConcept(BaseTest):
|
||||
@pytest.fixture()
|
||||
def evaluator(self, sheerka):
|
||||
return sheerka.evaluators[ResolvePythonVsSimpleConcept.NAME]
|
||||
|
||||
def test_i_can_match_and_eval(self, context, evaluator):
|
||||
python = _rv("some_value", who=PythonParser.NAME)
|
||||
concept = _rv("some_value", who=RecognizeSimpleConcept.NAME)
|
||||
other = _rv("some_value", who=RecognizeDefConcept.NAME)
|
||||
python_nok = _rvf("some_value", who=PythonParser.NAME)
|
||||
concept_nok = _rvf("some_value", who=RecognizeSimpleConcept.NAME)
|
||||
other_nok = _rvf("some_value", who=RecognizeDefConcept.NAME)
|
||||
|
||||
# at least the two
|
||||
return_values = [python, concept]
|
||||
m = evaluator.matches(context, return_values)
|
||||
assert m.status is True
|
||||
assert m.obj == {'to_keep': concept, 'to_drop': python, 'others': []}
|
||||
|
||||
r = evaluator.eval(context, m.obj, return_values)
|
||||
assert r.new == [concept]
|
||||
assert r.eaten == [python]
|
||||
|
||||
# the two and other successful
|
||||
return_values = [python, concept, other, other_nok]
|
||||
m = evaluator.matches(context, return_values)
|
||||
assert m.status is True
|
||||
assert m.obj == {'to_keep': concept, 'to_drop': python, 'others': [other, other_nok]}
|
||||
|
||||
r = evaluator.eval(context, m.obj, return_values)
|
||||
assert r.new == [concept, other, other_nok]
|
||||
assert r.eaten == [python]
|
||||
|
||||
# python is not ok
|
||||
return_values = [python_nok, concept]
|
||||
m = evaluator.matches(context, return_values)
|
||||
assert m.status is False
|
||||
|
||||
# concept is not ok
|
||||
return_values = [python, concept_nok]
|
||||
m = evaluator.matches(context, return_values)
|
||||
assert m.status is False
|
||||
|
||||
# neither is not
|
||||
return_values = [python_nok, concept_nok]
|
||||
m = evaluator.matches(context, return_values)
|
||||
assert m.status is False
|
||||
Reference in New Issue
Block a user