diff options
author | Nathan Fritz <nathan@andyet.net> | 2010-05-21 04:09:04 +0800 |
---|---|---|
committer | Thom Nichols <tmnichols@gmail.com> | 2010-06-01 22:07:50 +0800 |
commit | 0b2cd176b18f3e94e5565c62a781d74fe92cb149 (patch) | |
tree | 83b0d48bec4c14f34925df6fe58ac1650ddaae30 /tests | |
parent | 56b5cbe5b1a283745accadb59275b51b0c2dd9bb (diff) | |
download | slixmpp-0b2cd176b18f3e94e5565c62a781d74fe92cb149.tar.gz slixmpp-0b2cd176b18f3e94e5565c62a781d74fe92cb149.tar.bz2 slixmpp-0b2cd176b18f3e94e5565c62a781d74fe92cb149.tar.xz slixmpp-0b2cd176b18f3e94e5565c62a781d74fe92cb149.zip |
added test_events and testing new del_event_handler
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_events.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_events.py b/tests/test_events.py new file mode 100644 index 00000000..11821dbb --- /dev/null +++ b/tests/test_events.py @@ -0,0 +1,35 @@ +import unittest + +class testevents(unittest.TestCase): + + def setUp(self): + import sleekxmpp.stanza.presence as p + self.p = p + + def testEventHappening(self): + "Test handler working" + import sleekxmpp + c = sleekxmpp.ClientXMPP('crap@wherever', 'password') + happened = [] + def handletestevent(event): + happened.append(True) + c.add_event_handler("test_event", handletestevent) + c.event("test_event", {}) + c.event("test_event", {}) + self.failUnless(happened == [True, True], "event did not get triggered twice") + + def testDelEvent(self): + "Test handler working, then deleted and not triggered" + import sleekxmpp + c = sleekxmpp.ClientXMPP('crap@wherever', 'password') + happened = [] + def handletestevent(event): + happened.append(True) + c.add_event_handler("test_event", handletestevent) + c.event("test_event", {}) + c.del_event_handler("test_event", handletestevent) + c.event("test_event", {}) # should not trigger because it was deleted + self.failUnless(happened == [True], "event did not get triggered the correct number of times") + + +suite = unittest.TestLoader().loadTestsFromTestCase(testevents) |