summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoe Hildebrand <joe-github@cursive.net>2012-10-29 10:03:32 -0600
committerJoe Hildebrand <joe-github@cursive.net>2012-10-29 10:03:32 -0600
commit75a18b5ffe9057e234403e54a16e24bb2cc7ba25 (patch)
tree8757c7eafec0ae2c27f02ce4391b5dee6b86cb07 /tests
parent06a690a2592cba388877391935ed4168d101a231 (diff)
downloadslixmpp-75a18b5ffe9057e234403e54a16e24bb2cc7ba25.tar.gz
slixmpp-75a18b5ffe9057e234403e54a16e24bb2cc7ba25.tar.bz2
slixmpp-75a18b5ffe9057e234403e54a16e24bb2cc7ba25.tar.xz
slixmpp-75a18b5ffe9057e234403e54a16e24bb2cc7ba25.zip
Allow IQ timeouts to be asynchronous, by passing a timeout_callback parameter to send(). An example modification of disco is included. If this approach is approved, I'll go through and update the other plugins.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_handlers.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py
index 7fd4e648..cdd128bb 100644
--- a/tests/test_stream_handlers.py
+++ b/tests/test_stream_handlers.py
@@ -153,6 +153,35 @@ class TestHandlers(SleekTest):
self.failUnless(events == ['foo'],
"Iq callback was not executed: %s" % events)
+ def testIqTimeoutCallback(self):
+ """Test that iq.send(tcallback=handle_foo, timeout_callback=handle_timeout) works."""
+ events = []
+
+ def handle_foo(iq):
+ events.append('foo')
+
+ def handle_timeout(iq):
+ events.append('timeout')
+
+ iq = self.Iq()
+ iq['type'] = 'get'
+ iq['id'] = 'test-foo'
+ iq['to'] = 'user@localhost'
+ iq['query'] = 'foo'
+ iq.send(callback=handle_foo, timeout_callback=handle_timeout, timeout=0.05)
+
+ self.send("""
+ <iq type="get" id="test-foo" to="user@localhost">
+ <query xmlns="foo" />
+ </iq>
+ """)
+
+ # Give event queue time to process
+ time.sleep(0.1)
+
+ self.failUnless(events == ['timeout'],
+ "Iq timeout was not executed: %s" % events)
+
def testMultipleHandlersForStanza(self):
"""
Test that multiple handlers for a single stanza work