'Test using client-side error API for commands.'

def testClientAPIError(self):

    results = []
    def handle_error(iq, session):
        for item in session['custom_data']:
            results.append(item)
    session = {'custom_data': ['foo'], 'error': handle_error}
    self.xmpp['xep_0050'].start_command('foo@example.com', 'test_client', session)
    self.send('\n                                        <iq    id="1"    to="foo@example.com"    type="set">\n                                                <command    xmlns="http://jabber.org/protocol/commands"\n                                                                                    node="test_client"\n                                                                                    action="execute"    />\n                                        </iq>\n                                ')
    self.recv('\n                                        <iq    id="1"    to="foo@example.com"    type="error">\n                                                <command    xmlns="http://jabber.org/protocol/commands"\n                                                                                    node="test_client"\n                                                                                    action="execute"    />\n                                                <error    type=\'cancel\'>\n                                                        <item-not-found    xmlns=\'urn:ietf:params:xml:ns:xmpp-stanzas\'/>\n                                                </error>\n                                        </iq>\n                                ')
    time.sleep(0.3)
    self.failUnless((results == ['foo']), ('Incomplete    command    workflow:    %s' % results))
