summaryrefslogtreecommitdiff
path: root/tests/test_stream_handlers.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-12-13 14:36:53 -0500
committerLance Stout <lancestout@gmail.com>2010-12-13 14:36:53 -0500
commitc16913c99929a6a5a57611ec8a1757e3e82d4a45 (patch)
treed92b98975b3dc012c734997e6fddc0ac9e2b82d8 /tests/test_stream_handlers.py
parent12b61365adbbc910841475ea3cf8204f26ccd9c7 (diff)
parentf4451fe6b72f7cfb9680ead7a608d5ca1bc7e753 (diff)
downloadslixmpp-c16913c99929a6a5a57611ec8a1757e3e82d4a45.tar.gz
slixmpp-c16913c99929a6a5a57611ec8a1757e3e82d4a45.tar.bz2
slixmpp-c16913c99929a6a5a57611ec8a1757e3e82d4a45.tar.xz
slixmpp-c16913c99929a6a5a57611ec8a1757e3e82d4a45.zip
Merge branch 'develop' into roster
Conflicts: sleekxmpp/basexmpp.py
Diffstat (limited to 'tests/test_stream_handlers.py')
-rw-r--r--tests/test_stream_handlers.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py
index 2b878b37..a475b36c 100644
--- a/tests/test_stream_handlers.py
+++ b/tests/test_stream_handlers.py
@@ -1,3 +1,5 @@
+import time
+
from sleekxmpp.test import *
from sleekxmpp.xmlstream.handler import *
from sleekxmpp.xmlstream.matcher import *
@@ -108,5 +110,41 @@ class TestHandlers(SleekTest):
self.failUnless(waiter_exists == False,
"Waiter handler was not removed.")
+ def testIqCallback(self):
+ """Test that iq.send(callback=handle_foo) works."""
+ events = []
+
+ def handle_foo(iq):
+ events.append('foo')
+
+ iq = self.Iq()
+ iq['type'] = 'get'
+ iq['id'] = 'test-foo'
+ iq['to'] = 'user@localhost'
+ iq['query'] = 'foo'
+ iq.send(callback=handle_foo)
+
+ self.send("""
+ <iq type="get" id="test-foo" to="user@localhost">
+ <query xmlns="foo" />
+ </iq>
+ """)
+
+ self.recv("""
+ <iq type="result" id="test-foo"
+ to="test@localhost"
+ from="user@localhost">
+ <query xmlns="foo">
+ <data />
+ </query>
+ </iq>
+ """)
+
+ # Give event queue time to process
+ time.sleep(0.1)
+
+ self.failUnless(events == ['foo'],
+ "Iq callback was not executed: %s" % events)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestHandlers)