Files
Sheerka-Old/tests/core/test_SheerkaHistoryManager.py
T
kodjo cac2dad17f 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
2021-02-12 15:15:31 +01:00

50 lines
1.8 KiB
Python

from core.sheerka.services.SheerkaHistoryManager import hist, SheerkaHistoryManager
from tests.TestUsingFileBasedSheerka import TestUsingFileBasedSheerka
class TestSheerkaHistoryManager(TestUsingFileBasedSheerka):
def test_i_can_retrieve_history(self):
sheerka = self.get_sheerka()
service = sheerka.services[SheerkaHistoryManager.NAME]
sheerka.save_execution_context = True
sheerka.evaluate_user_input("def concept one as 1")
sheerka.evaluate_user_input("one")
sheerka.evaluate_user_input("xxx")
sheerka.evaluate_user_input("def concept two as 2")
sheerka.evaluate_user_input("two")
sheerka.evaluate_user_input("def concept three as 3")
sheerka.evaluate_user_input("three")
sheerka.evaluate_user_input("def concept four as 4")
sheerka.evaluate_user_input("four")
sheerka.evaluate_user_input("def concept five as 5")
sheerka.evaluate_user_input("five")
h = list(service.history(-1)) # all
assert h == [
hist("five", True),
hist("def concept five as 5", True),
hist("four", True),
hist("def concept four as 4", True),
hist("three", True),
hist("def concept three as 3", True),
hist("two", True),
hist("def concept two as 2", True),
hist("xxx", False),
hist("one", True),
hist("def concept one as 1", True),
hist("Initializing Sheerka.", None)
]
h = list(service.history(2))
assert h == [
hist("five", True),
hist("def concept five as 5", True)
]
h = list(service.history(2, 2))
assert h == [
hist("four", True),
hist("def concept four as 4", True),
]