'Test that iq.send(tcallback=handle_foo, timeout_callback=handle_timeout) works.'

def testIqTimeoutCallback(self):

    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('\n                                        <iq    type="get"    id="test-foo"    to="user@localhost">\n                                                <query    xmlns="foo"    />\n                                        </iq>\n                                ')
    time.sleep(1)
    self.failUnless((events == ['timeout']), ('Iq    timeout    was    not    executed:    %s' % events))
