Implemented some enhancement request and fixed some bugs
Fixed #2 : Variables are not recognized when inside a rule token Fixed #15 : Rule: rete attributes are lost when a new ontology is created Fixed #14 : ReteNetwork: Format rules must not be added to Rete network Fixed #16 : DefConcept: Variables are not recognized when they are keyword arguments Fixed #4 : Comparison are not correctly set when comparison property is a concept Fixed #14 : Parser: merge FunctionParser.NamesNode and ExpressionParser.NamesNode Fixed #18 : Parser: Add SourceCodeNode test to UnrecognizedNodeParser Fixed #20 : At startup Number concept is saved in db a numerous number of time Fixed #21 : CacheManager: I can remove all elements from a ListIfNeededCache and fill it again Fixed #22 : CacheManager: I can remove all elements from a SetCache and fill it again Fixed #23 : HistoryManager: history() no longer works Fixed #24 : HistoryManager: history() no longer works after creating an exec rule Fixed #25 : SheerkaMemory: Use MemoryObject instead of sheerka.local Fixed #26 : Debugger: add the list all available services.. Fixed #27 : CONCEPTS_GRAMMARS_ENTRY does not seems to be in use any more Fixed #28 : Give order to services
This commit is contained in:
@@ -3,7 +3,7 @@ import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
from core.global_symbols import EVENT_CONCEPT_PRECEDENCE_MODIFIED, CONCEPT_COMPARISON_CONTEXT, \
|
||||
EVENT_RULE_PRECEDENCE_MODIFIED, RULE_COMPARISON_CONTEXT
|
||||
EVENT_RULE_PRECEDENCE_MODIFIED, RULE_COMPARISON_CONTEXT, NotFound
|
||||
from core.sheerka.services.SheerkaComparisonManager import SheerkaComparisonManager, ComparisonObj
|
||||
from core.sheerka.services.SheerkaConceptManager import ChickenAndEggError
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
@@ -367,8 +367,8 @@ class TestSheerkaGreaterThanManager(TestUsingMemoryBasedSheerka):
|
||||
sheerka.set_is_less_than(context, "prop_name", less_l, lesser)
|
||||
sheerka.set_is_greater_than(context, "prop_name", less_l, even_more_l)
|
||||
assert service.get_weights("prop_name") == {"c:lesser|1001:": 0,
|
||||
"c:less_l|1002:": -1,
|
||||
"c:even_less_l|1003:": -2}
|
||||
"c:less_l|1002:": -1,
|
||||
"c:even_less_l|1003:": -2}
|
||||
|
||||
def test_i_cannot_define_less_than_a_lesser_if_not_a_lesser_itself(self):
|
||||
"""
|
||||
@@ -438,8 +438,8 @@ class TestSheerkaGreaterThanManager(TestUsingMemoryBasedSheerka):
|
||||
sheerka.set_is_less_than(context, "prop_name", greatest, more_g)
|
||||
sheerka.set_is_greater_than(context, "prop_name", even_more_g, more_g)
|
||||
assert service.get_weights("prop_name") == {"c:greatest|1001:": 2,
|
||||
"c:more_g|1002:": 3,
|
||||
"c:even_more_g|1003:": 4}
|
||||
"c:more_g|1002:": 3,
|
||||
"c:even_more_g|1003:": 4}
|
||||
|
||||
def test_i_can_mix_all_comparisons(self):
|
||||
sheerka, context, one, two, three, four, five, six, three_and_half = self.init_concepts(
|
||||
@@ -657,7 +657,7 @@ class TestSheerkaGreaterThanManager(TestUsingMemoryBasedSheerka):
|
||||
(["a = z", "z>>", "b<c", "c<d"], {"a": 4, "b": 1, "c": 2, "d": 3, "z": 4}),
|
||||
(["b = a", "c = b", "a > d"], {"a": 2, "b": 2, "c": 2, "d": 1}),
|
||||
(["a = b", "b = c", "a > d"], {"a": 2, "b": 2, "c": 2, "d": 1}),
|
||||
#(["a = b", "b = c", "c > d"], {"a": 2, "b": 2, "c": 2, "d": 1}), # not working
|
||||
# (["a = b", "b = c", "c > d"], {"a": 2, "b": 2, "c": 2, "d": 1}), # not working
|
||||
|
||||
# mix greatest and lesser
|
||||
(["a >>", "b<<", "a > b"], {"a": 2, "b": 0}),
|
||||
@@ -732,3 +732,25 @@ class TestSheerkaGreaterThanManager(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert not res.status
|
||||
assert sheerka.isinstance(res.body, BuiltinConcepts.IS_LESSER_CONSTRAINT_ERROR)
|
||||
|
||||
def test_i_can_seamlessly_use_concept_name_or_concept_itself_when_builtin_concept_to_define_comparison(self):
|
||||
sheerka, context, foo, bar, baz = self.init_concepts("foo", "bar", "baz")
|
||||
|
||||
prec_as_concept = sheerka.new(BuiltinConcepts.PRECEDENCE)
|
||||
sheerka.set_is_greater_than(context, BuiltinConcepts.PRECEDENCE, foo, bar)
|
||||
sheerka.set_is_greater_than(context, prec_as_concept, foo, baz)
|
||||
|
||||
assert sheerka.om.get(SheerkaComparisonManager.COMPARISON_ENTRY, f"{BuiltinConcepts.PRECEDENCE}|#") == [
|
||||
ComparisonObj(context.event.get_digest(), BuiltinConcepts.PRECEDENCE, foo.str_id, bar.str_id, ">", "#"),
|
||||
ComparisonObj(context.event.get_digest(), BuiltinConcepts.PRECEDENCE, foo.str_id, baz.str_id, ">", "#"),
|
||||
]
|
||||
assert sheerka.om.get(SheerkaComparisonManager.COMPARISON_ENTRY, f"{prec_as_concept.str_id}|#") is NotFound
|
||||
|
||||
def test_i_can_seamlessly_use_concept_id_or_concept_itself_to_define_comparison(self):
|
||||
sheerka, context, foo, bar, baz, op = self.init_concepts("foo", "bar", "baz", "op")
|
||||
sheerka.set_is_greater_than(context, op.str_id, foo, bar)
|
||||
sheerka.set_is_greater_than(context, op, foo, baz)
|
||||
assert sheerka.om.get(SheerkaComparisonManager.COMPARISON_ENTRY, f"{op.str_id}|#") == [
|
||||
ComparisonObj(context.event.get_digest(), op.str_id, foo.str_id, bar.str_id, ">", "#"),
|
||||
ComparisonObj(context.event.get_digest(), op.str_id, foo.str_id, baz.str_id, ">", "#"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user