'Test send when there is no established XML stream.
The data should be cached until an XML stream has been established and
initialized.'

def test_sendNotConnected(self):

    factory = xmlstream.XmlStreamFactory(xmlstream.Authenticator())
    sm = xmlstream.StreamManager(factory)
    handler = DummyXMPPHandler()
    sm.addHandler(handler)
    xs = factory.buildProtocol(None)
    xs.transport = proto_helpers.StringTransport()
    sm.send('<presence/>')
    self.assertEqual('', xs.transport.value())
    self.assertEqual('<presence/>', sm._packetQueue[0])
    xs.connectionMade()
    self.assertEqual('', xs.transport.value())
    self.assertEqual('<presence/>', sm._packetQueue[0])
    xs.dataReceived("<stream:stream    xmlns='jabber:client'    xmlns:stream='http://etherx.jabber.org/streams'    from='example.com'    id='12345'>")
    xs.dispatch(xs, '//event/stream/authd')
    self.assertEqual('<presence/>', xs.transport.value())
    self.assertFalse(sm._packetQueue)
