'Test a command with an initial payload.'

def testInitialPayloadCommand(self):

    class TestPayload(ElementBase, ):
        name = 'foo'
        namespace = 'test'
        interfaces = set(['bar'])
        plugin_attrib = name
    Command = self.xmpp['xep_0050'].stanza.Command
    register_stanza_plugin(Command, TestPayload, iterable=True)
    def handle_command(iq, session):
        initial = session['payload']
        logging.debug(initial)
        new_payload = TestPayload()
        if initial:
            new_payload['bar'] = ('Received:    %s' % initial['bar'])
        else:
            new_payload['bar'] = 'Failed'
        logging.debug(initial)
        session['payload'] = new_payload
        session['next'] = None
        session['has_next'] = False
        return session
    self.xmpp['xep_0050'].add_command('tester@localhost', 'foo', 'Do    Foo', handle_command)
    self.recv('\n                                        <iq    id="11"    type="set"    to="tester@localhost"    from="foo@bar">\n                                                <command    xmlns="http://jabber.org/protocol/commands"\n                                                                                    node="foo"\n                                                                                    action="execute">\n                                                        <foo    xmlns="test"    bar="baz"    />\n                                                </command>\n                                        </iq>\n                                ')
    self.send('\n                                        <iq    id="11"    type="result"    to="foo@bar">\n                                                <command    xmlns="http://jabber.org/protocol/commands"\n                                                                                    node="foo"\n                                                                                    status="completed"\n                                                                                    sessionid="_sessionid_">\n                                                        <foo    xmlns="test"    bar="Received:    baz"    />\n                                                </command>\n                                        </iq>\n                                ')
