summaryrefslogtreecommitdiff
path: root/tests/test_events.py
diff options
context:
space:
mode:
authorThom Nichols <tmnichols@gmail.com>2010-06-01 22:54:30 -0400
committerThom Nichols <tmnichols@gmail.com>2010-06-01 22:54:30 -0400
commit49f5767aea2815211349d93aa03ce2b9dc088c1e (patch)
tree3a63f08d009dc7d16560ac2fc464482649b4cd47 /tests/test_events.py
parent3e83b16a586b34dd686a4aeaea77c50a92f54b51 (diff)
parente6c2fde2834fafbc35b52da7e523f2b351f53a15 (diff)
downloadslixmpp-49f5767aea2815211349d93aa03ce2b9dc088c1e.tar.gz
slixmpp-49f5767aea2815211349d93aa03ce2b9dc088c1e.tar.bz2
slixmpp-49f5767aea2815211349d93aa03ce2b9dc088c1e.tar.xz
slixmpp-49f5767aea2815211349d93aa03ce2b9dc088c1e.zip
merged changes from fritzy
Diffstat (limited to 'tests/test_events.py')
-rw-r--r--tests/test_events.py35
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)