From 3d41146af5f136d156b5a1f0c65c553612fbd4b2 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 19 Mar 2009 19:50:19 +0000 Subject: TutoriusV2 : Adding more tests on States (action management) --- (limited to 'src') diff --git a/src/sugar/tutorius/core.py b/src/sugar/tutorius/core.py index d0fc3cb..1bf81db 100644 --- a/src/sugar/tutorius/core.py +++ b/src/sugar/tutorius/core.py @@ -208,7 +208,7 @@ class State(object): Removes all the action associated with this state. A cleared state will not do anything when entered or exited. """ - self._actions.clear() + self._actions = [] def add_event_filter(self, event_filter): """ diff --git a/src/sugar/tutorius/tests/coretests.py b/src/sugar/tutorius/tests/coretests.py index 6b86cb9..af3f02c 100644 --- a/src/sugar/tutorius/tests/coretests.py +++ b/src/sugar/tutorius/tests/coretests.py @@ -207,6 +207,38 @@ class StateTest(unittest.TestCase): assert False, "No RuntimeWarning was raised on second set_tutorial" except : pass + + def test_add_action(self): + """ + Tests on manipulating the actions inside a state. + """ + state = State("INIT") + + act1 = CountAction() + act2 = CountAction() + act3 = CountAction() + + # Try to add the actions + assert state.add_action(act1), "Could not add the first action" + assert state.add_action(act2), "Could not add the second action" + assert state.add_action(act3), "Could not add the third action" + + # Try to add a second time an action that was already inserted + assert state.add_action(act1) == False, "Not supposed to insert an action twice" + + # Fetch the associated actions + actions = state.get_action_list() + + # Make sure all the actions are present in the state + assert act1 in actions and act2 in actions and act3 in actions,\ + "The actions were not properly inserted in the state" + + # Clear the list + state.clear_actions() + + # Make sure the list of actions is empty now + assert len(state.get_action_list()) == 0, "Clearing of actions failed" + class FSMTest(unittest.TestCase): """ -- cgit v0.9.1