Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-11-26 23:03:38 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-11-26 23:03:38 (GMT)
commitb290d0384ea13319026ddcaeca5d567a2556f0e3 (patch)
tree5ad586b7000d023c8ac0d37f72bb392a6449da2e /tests
parenta6bdbdecfbe53924dc8e38768aed1d8037be6143 (diff)
LP 448319 : Code review changes 2
Diffstat (limited to 'tests')
-rw-r--r--tests/enginetests.py57
-rw-r--r--tests/probetests.py14
2 files changed, 6 insertions, 65 deletions
diff --git a/tests/enginetests.py b/tests/enginetests.py
index 2d1e723..f24aedb 100644
--- a/tests/enginetests.py
+++ b/tests/enginetests.py
@@ -49,60 +49,6 @@ class MockProbeMgrMultiAddons(object):
currentActivity = property(fget=lambda s:s, fset=lambda s, v: v)
def run_install_cb(self, action_number, action):
- self._action_installed_cb_list[action_number](action, str(uuid1()))
-
- def run_install_error_cb(self, action_number):
- self._install_error_cb_list[action_number](Exception("Could not install action..."))
-
- def run_subscribe_cb(self, event_number):
- self._event_subscribed_cb_list[event_number](str(uuid1()))
-
- def run_subscribe_error(self, event_number):
- self._subscribe_error_cb_list[event_number](str(uuid1()))
-
- def install(self, action, action_installed_cb, error_cb):
- action_address = str(uuid1())
- self.action_dict[action_address] = action
- self._action_installed_cb_list.append(action_installed_cb)
- self._install_error_cb_list.append(error_cb)
-
- def update(self, action_address, new_action):
- self.action_dict[action_address] = new_action
-
- def uninstall(self, action_address):
- del self.action_dict[action_address]
-
- def subscribe(self, event_name, event, notif_cb, subscribe_cb, error_cb):
- event_address = str(uuid1())
- self.event_dict[event_name] = event_address
- self.event_cb_dict[event_name] = notif_cb
- self._event_subscribed_cb_list.append(subscribe_cb)
- self._subscribe_error_cb_list.append(error_cb)
-
- def unsubscribe(self, address):
- for (event_name, other_event) in self.event_dict.values():
- if event == othet_event:
- del self.event_dict[event_name]
- break
-
-class MockProbeMgrMultiAddons(object):
- """
- Mock probe manager that supports installing more than one action
- at the time.
- """
- def __init__(self):
- self.action_dict = {}
- self.event_dict = {}
- self.event_cb_dict = {}
-
- self._action_installed_cb_list = []
- self._install_error_cb_list = []
- self._event_subscribed_cb_list = []
- self._subscribe_error_cb_list = []
-
- currentActivity = property(fget=lambda s:s, fset=lambda s, v: v)
-
- def run_install_cb(self, action_number, action):
self._action_installed_cb_list[action_number](str(uuid1()))
def run_install_error_cb(self, action_number):
@@ -112,7 +58,7 @@ class MockProbeMgrMultiAddons(object):
self._event_subscribed_cb_list[event_number](str(uuid1()))
def run_subscribe_error(self, event_number):
- self._subscribe_error_cb_list[event_number](str(uuid1()))
+ self._subscribe_error_cb_list[event_number](Exception("Could not subscribe to event"))
def install(self, action, action_installed_cb, error_cb):
action_address = str(uuid1())
@@ -248,7 +194,6 @@ class TestInstallationStates(unittest.TestCase):
self.state_name = self.tutorial.add_state()
self.tutorial.update_transition(Tutorial.INITIAL_TRANSITION_NAME,
None, self.state_name)
- #import rpdb2; rpdb2.start_embedded_debugger('pass')
self.action1 = CountAction()
self.tutorial.add_action(self.state_name, self.action1)
self.action2 = CountAction()
diff --git a/tests/probetests.py b/tests/probetests.py
index d43da8e..8dbac29 100644
--- a/tests/probetests.py
+++ b/tests/probetests.py
@@ -113,9 +113,8 @@ class MockProbeProxy(object):
self.MockActionUpdate = None
return None
- def subscribe(self, event_name, event, notif_cb, subscribe_cb, error_cb):
+ def subscribe(self, event, notif_cb, subscribe_cb, error_cb):
#Do like the current Probe
- self.MockEventName = event_name
self.MockEvent = event
self.MockCB = notif_cb
self.MockSubscribeCB = subscribe_cb
@@ -383,8 +382,6 @@ class ProbeManagerTest(unittest.TestCase):
act1 = self.probeManager.get_registered_probes_list("act1")[0][1]
act2 = self.probeManager.get_registered_probes_list("act2")[0][1]
- event_name1 = 'State0/event0'
- event_name2 = 'State0/event1'
ad1 = MockAddon()
ad2 = MockAddon()
ad2.i, ad2.s = (2, "test2")
@@ -396,13 +393,13 @@ class ProbeManagerTest(unittest.TestCase):
#ErrorCase: unsubscribe and subscribe without current activity
#Event functions should do a warning if there is no activity
- self.assertRaises(RuntimeWarning, self.probeManager.subscribe, event_name1, ad1, cb1, install_cb1, error_cb1)
+ self.assertRaises(RuntimeWarning, self.probeManager.subscribe, ad1, cb1, install_cb1, error_cb1)
self.assertRaises(RuntimeWarning, self.probeManager.unsubscribe, None)
assert act1.MockEvent is None, "No event should be on act1"
assert act2.MockEvent is None, "No event should be on act2"
self.probeManager.currentActivity = "act1"
- self.probeManager.subscribe(event_name1, ad1, cb1, install_cb1, error_cb1)
+ self.probeManager.subscribe(ad1, cb1, install_cb1, error_cb1)
assert act1.MockEvent == ad1, "Event should have been installed"
assert act1.MockCB == cb1, "Callback should have been set"
assert act2.MockEvent is None, "No event should be on act2"
@@ -484,13 +481,12 @@ class ProbeProxyTest(unittest.TestCase):
address = "Addr1"
#Set the return value of probe subscribe
self.mockObj.MockRet["subscribe"] = address
- self.probeProxy.subscribe('State0/event0', event, callback, subs_cb, error_cb)
- self.probeProxy._ProbeProxy__update_event('State0/event0', event, callback, subs_cb, event_address)
+ self.probeProxy.subscribe(event, callback, subs_cb, error_cb)
+ self.probeProxy._ProbeProxy__update_event(event, callback, subs_cb, event_address)
assert pickle.loads(self.mockObj.MockCall["subscribe"]["args"][0]) == event, "1 argument, the event"
#Call the callback with the event
global message_box
- #import rpdb2; rpdb2.start_embedded_debugger('pass')
self.mockObj.MockCB["eventOccured"]["handler_function"](pickle.dumps(event))
assert message_box == event, "callback should have been called with event"
message_box = None