Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/probetests.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-11-19 16:15:52 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-11-19 16:15:52 (GMT)
commit0a427dbd5acbcfee8874c30fb0a1c16473f1b93d (patch)
treef0eb125ce460835cd356575dacc49acd21548d4a /tests/probetests.py
parent88b3f3099252353e22c536a68e15e2a2f9b10334 (diff)
LP 448319 : Adding tests for translator, properties, constraints and probes, fixing Probe Proxy's uninstalltranslator_merge
Diffstat (limited to 'tests/probetests.py')
-rw-r--r--tests/probetests.py47
1 files changed, 28 insertions, 19 deletions
diff --git a/tests/probetests.py b/tests/probetests.py
index 59072e5..bdb9bc9 100644
--- a/tests/probetests.py
+++ b/tests/probetests.py
@@ -90,21 +90,23 @@ class MockProbeProxy(object):
self.MockCB = None
self.MockAlive = True
self.MockEventAddr = None
+ self.MockAddressCallback = None
def isAlive(self):
return self.MockAlive
- def install(self, action, block=False):
+ def install(self, action, callback, block=False):
self.MockAction = action
+ self.MockAddressCallback_install = callback
self.MockActionUpdate = None
return None
- def update(self, action, newaction, block=False):
- self.MockAction = action
+ def update(self, action_address, newaction, block=False):
+ self.MockActionAddress = action_address
self.MockActionUpdate = newaction
return None
- def uninstall(self, action, block=False):
+ def uninstall(self, action_address, block=False):
self.MockAction = None
self.MockActionUpdate = None
return None
@@ -114,7 +116,7 @@ class MockProbeProxy(object):
if not block:
raise RuntimeError("This function does not allow non-blocking mode yet")
- self.MockEvent= event
+ self.MockEvent = event
self.MockCB = callback
return str(id(event))
@@ -343,29 +345,32 @@ class ProbeManagerTest(unittest.TestCase):
act2 = self.probeManager.get_registered_probes_list("act2")[0][1]
ad1 = MockAddon()
+ ad1_address = "Address1"
+ def callback(value):
+ pass
#ErrorCase: install, update, uninstall without currentActivity
#Action functions should do a warning if there is no activity
- self.assertRaises(RuntimeWarning, self.probeManager.install, ad1)
- self.assertRaises(RuntimeWarning, self.probeManager.update, ad1, ad1)
- self.assertRaises(RuntimeWarning, self.probeManager.uninstall, ad1)
+ self.assertRaises(RuntimeWarning, self.probeManager.install, ad1, callback)
+ self.assertRaises(RuntimeWarning, self.probeManager.update, ad1_address, ad1)
+ self.assertRaises(RuntimeWarning, self.probeManager.uninstall, ad1_address)
assert act1.MockAction is None, "Action should not be installed on inactive proxy"
assert act2.MockAction is None, "Action should not be installed on inactive proxy"
self.probeManager.currentActivity = "act1"
- self.probeManager.install(ad1)
+ self.probeManager.install(ad1, callback)
assert act1.MockAction == ad1, "Action should have been installed"
assert act2.MockAction is None, "Action should not be installed on inactive proxy"
- self.probeManager.update(ad1, ad1)
+ self.probeManager.update(ad1_address, ad1)
assert act1.MockActionUpdate == ad1, "Action should have been updated"
assert act2.MockActionUpdate is None, "Should not update on inactive"
self.probeManager.currentActivity = "act2"
- self.probeManager.uninstall(ad1)
- assert act1.MockAction == ad1, "Action should still be installed"
+ self.probeManager.uninstall(ad1_address)
+ assert act1.MockActionAddress == ad1_address, "Action should still be installed"
self.probeManager.currentActivity = "act1"
- self.probeManager.uninstall(ad1)
+ self.probeManager.uninstall(ad1_address)
assert act1.MockAction is None, "Action should be uninstalled"
def test_events(self):
@@ -398,7 +403,6 @@ class ProbeManagerTest(unittest.TestCase):
assert act1.MockEventAddr == "SomeAddress", "Unsubscribe should have been called"
assert act2.MockEventAddr is None, "Unsubscribe should not have been called"
-
class ProbeProxyTest(unittest.TestCase):
def setUp(self):
dbus.SessionBus = MockSessionBus
@@ -422,29 +426,34 @@ class ProbeProxyTest(unittest.TestCase):
action.i, action.s = 5, "action"
action2 = MockAddon()
action2.i, action2.s = 10, "action2"
+ action2_address = "Addr2"
#Check if the installed action is the good one
address = "Addr1"
+
+ def callback(value):
+ pass
+
#Set the return value of probe install
self.mockObj.MockRet["install"] = address
- self.probeProxy.install(action, block=True)
+ self.probeProxy.install(action, callback, block=True)
assert pickle.loads(self.mockObj.MockCall["install"]["args"][0]) == action, "1 argument, the action"
#ErrorCase: Update should fail on noninstalled actions
- self.assertRaises(RuntimeWarning, self.probeProxy.update, action2, action2, block=True)
+ self.assertRaises(RuntimeWarning, self.probeProxy.update, action2_address, action2, block=True)
#Test the update
- self.probeProxy.update(action, action2, block=True)
+ self.probeProxy.update(address, action2, block=True)
args = self.mockObj.MockCall["update"]["args"]
assert args[0] == address, "arg 1 should be the action address"
assert pickle.loads(args[1]) == action2._props, "arg2 should be the new action properties"
#ErrorCase: Uninstall on not installed action (silent fail)
#Test the uninstall
- self.probeProxy.uninstall(action2, block=True)
+ self.probeProxy.uninstall(action2_address, block=True)
assert not "uninstall" in self.mockObj.MockCall, "Uninstall should not be called if action is not installed"
- self.probeProxy.uninstall(action, block=True)
+ self.probeProxy.uninstall(address, block=True)
assert self.mockObj.MockCall["uninstall"]["args"][0] == address, "1 argument, the action address"
def test_events(self):