summaryrefslogtreecommitdiff
path: root/src/leap/common/tests/test_events.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-06-09 14:16:33 -0300
committerdrebs <drebs@leap.se>2013-06-13 11:46:21 -0300
commita08b198d889396d25182bb9716817311bcc3be47 (patch)
tree0ec1938b79b527ed94e9d54a21122ce88c0dab39 /src/leap/common/tests/test_events.py
parentdbbf33d27268266088ee1ab15fc04cef33259250 (diff)
Add possibility of unregistering in events mechanism.
Diffstat (limited to 'src/leap/common/tests/test_events.py')
-rw-r--r--src/leap/common/tests/test_events.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/leap/common/tests/test_events.py b/src/leap/common/tests/test_events.py
index 8c0bd36..7286bdc 100644
--- a/src/leap/common/tests/test_events.py
+++ b/src/leap/common/tests/test_events.py
@@ -198,3 +198,36 @@ class EventsTestCase(unittest.TestCase):
response = events.signal(sig)
self.assertTrue(response.status == response.OK,
'Received wrong response status when signaling.')
+
+ def test_component_unregister_all(self):
+ """
+ Test that the component can unregister all events for one signal.
+ """
+ sig = CLIENT_UID
+ complist = server.registered_components
+ events.register(sig, lambda x: True)
+ events.register(sig, lambda x: True)
+ time.sleep(0.1)
+ events.unregister(sig)
+ time.sleep(0.1)
+ port = component.EventsComponentDaemon.get_instance().get_port()
+ self.assertFalse(bool(complist[sig]))
+ self.assertTrue(port not in complist[sig])
+
+ def test_component_unregister_by_uid(self):
+ """
+ Test that the component can unregister an event by uid.
+ """
+ sig = CLIENT_UID
+ complist = server.registered_components
+ events.register(sig, lambda x: True, uid='cbkuid')
+ events.register(sig, lambda x: True, uid='cbkuid2')
+ time.sleep(0.1)
+ events.unregister(sig, uid='cbkuid')
+ time.sleep(0.1)
+ port = component.EventsComponentDaemon.get_instance().get_port()
+ self.assertTrue(sig in complist)
+ self.assertTrue(len(complist[sig]) == 1)
+ self.assertTrue(
+ component.registered_callbacks[sig].pop()[0] == 'cbkuid2')
+ self.assertTrue(port in complist[sig])