Ignore:
Timestamp:
Oct 3, 2016, 8:49:10 AM (4 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
rebase_source:
77cb4411a2525cb7b972b664a751e11c11b7cf65
Message:

imported patch py3-subprotocols.patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_subprotocols.py

    r165 r194  
    55Tests for L{wokkel.subprotocols}
    66"""
     7
     8from __future__ import division, absolute_import
    79
    810from zope.interface.verify import verifyObject
     
    211213        self.xmlstream.connectionMade()
    212214        self.xmlstream.dataReceived(
    213                 "<stream:stream xmlns='jabber:client' "
    214                     "xmlns:stream='http://etherx.jabber.org/streams' "
    215                     "from='example.com' id='12345'>")
     215                b"<stream:stream xmlns='jabber:client' "
     216                    b"xmlns:stream='http://etherx.jabber.org/streams' "
     217                    b"from='example.com' id='12345'>")
    216218        self.xmlstream.dispatch(self.xmlstream, "//event/stream/authd")
    217219
     
    476478        xs.transport = proto_helpers.StringTransport()
    477479        xs.connectionMade()
    478         xs.dataReceived("<stream:stream xmlns='jabber:client' "
    479                         "xmlns:stream='http://etherx.jabber.org/streams' "
    480                         "from='example.com' id='12345'>")
     480        xs.dataReceived(b"<stream:stream xmlns='jabber:client' "
     481                        b"xmlns:stream='http://etherx.jabber.org/streams' "
     482                        b"from='example.com' id='12345'>")
    481483        xs.dispatch(xs, "//event/stream/authd")
    482484        sm.send("<presence/>")
    483         self.assertEquals("<presence/>", xs.transport.value())
     485        self.assertEquals(b"<presence/>", xs.transport.value())
    484486
    485487
     
    499501        xs.transport = proto_helpers.StringTransport()
    500502        sm.send("<presence/>")
    501         self.assertEquals("", xs.transport.value())
     503        self.assertEquals(b"", xs.transport.value())
    502504        self.assertEquals("<presence/>", sm._packetQueue[0])
    503505
    504506        xs.connectionMade()
    505         self.assertEquals("", xs.transport.value())
     507        self.assertEquals(b"", xs.transport.value())
    506508        self.assertEquals("<presence/>", sm._packetQueue[0])
    507509
    508         xs.dataReceived("<stream:stream xmlns='jabber:client' "
    509                         "xmlns:stream='http://etherx.jabber.org/streams' "
    510                         "from='example.com' id='12345'>")
     510        xs.dataReceived(b"<stream:stream xmlns='jabber:client' "
     511                        b"xmlns:stream='http://etherx.jabber.org/streams' "
     512                        b"from='example.com' id='12345'>")
    511513        xs.dispatch(xs, "//event/stream/authd")
    512514
    513         self.assertEquals("<presence/>", xs.transport.value())
     515        self.assertEquals(b"<presence/>", xs.transport.value())
    514516        self.assertFalse(sm._packetQueue)
    515517
     
    526528        xs.transport = proto_helpers.StringTransport()
    527529        xs.connectionMade()
    528         xs.dataReceived("<stream:stream xmlns='jabber:client' "
    529                         "xmlns:stream='http://etherx.jabber.org/streams' "
    530                         "from='example.com' id='12345'>")
     530        xs.dataReceived(b"<stream:stream xmlns='jabber:client' "
     531                        b"xmlns:stream='http://etherx.jabber.org/streams' "
     532                        b"from='example.com' id='12345'>")
    531533        sm.send("<presence/>")
    532         self.assertEquals("", xs.transport.value())
     534        self.assertEquals(b"", xs.transport.value())
    533535        self.assertEquals("<presence/>", sm._packetQueue[0])
    534536
     
    552554
    553555        sm.send("<presence/>")
    554         self.assertEquals("", xs.transport.value())
     556        self.assertEquals(b"", xs.transport.value())
    555557        self.assertEquals("<presence/>", sm._packetQueue[0])
    556558
     
    563565
    564566        self.streamManager.request(self.request)
    565         expected = u"<iq type='get' id='%s'/>" % self.request.stanzaID
    566         self.assertEquals(expected, self.transport.value())
     567        self.assertTrue(self.transport.value())
    567568
    568569
     
    576577        self.streamManager.request(self.request)
    577578        self.assertNotIdentical(None, self.request.stanzaID)
    578         expected = u"<iq type='get' id='%s'/>" % self.request.stanzaID
    579         self.assertEquals(expected, self.transport.value())
     579        self.assertTrue(self.transport.value())
    580580
    581581
     
    588588
    589589        self.streamManager.request(self.request)
    590         expected = u"<iq type='get' id='test'/>"
    591590
    592591        xs = self.xmlstream
    593         self.assertEquals("", xs.transport.value())
     592        self.assertEquals(b"", xs.transport.value())
    594593
    595594        xs.connectionMade()
    596         self.assertEquals("", xs.transport.value())
    597 
    598         xs.dataReceived("<stream:stream xmlns='jabber:client' "
    599                         "xmlns:stream='http://etherx.jabber.org/streams' "
    600                         "from='example.com' id='12345'>")
     595        self.assertEquals(b"", xs.transport.value())
     596
     597        xs.dataReceived(b"<stream:stream xmlns='jabber:client' "
     598                        b"xmlns:stream='http://etherx.jabber.org/streams' "
     599                        b"from='example.com' id='12345'>")
    601600        xs.dispatch(xs, "//event/stream/authd")
    602601
    603         self.assertEquals(expected, xs.transport.value())
     602        self.assertTrue(self.transport.value())
    604603        self.assertFalse(self.streamManager._packetQueue)
    605604
     
    617616
    618617        xs = self.xmlstream
    619         xs.dataReceived("<iq type='result' id='test'/>")
     618        xs.dataReceived(b"<iq type='result' id='test'/>")
    620619        return d
    621620
     
    630629
    631630        xs = self.xmlstream
    632         xs.dataReceived("<iq type='error' id='test'/>")
     631        xs.dataReceived(b"<iq type='error' id='test'/>")
    633632        return d
    634633
     
    652651
    653652        # Receive an untracked iq response
    654         self.xmlstream.dataReceived("<iq type='result' id='other'/>")
     653        self.xmlstream.dataReceived(b"<iq type='result' id='other'/>")
    655654        self.assertEquals(1, len(dispatched))
    656655        self.assertFalse(getattr(dispatched[-1], 'handled', False))
     
    666665        d = self.streamManager.request(self.request)
    667666        xs = self.xmlstream
    668         xs.dataReceived("<iq type='result' id='test'/>")
     667        xs.dataReceived(b"<iq type='result' id='test'/>")
    669668        self.assertNotIn('test', self.streamManager._iqDeferreds)
    670669        return d
     
    722721        d = self.streamManager.request(self.request)
    723722        self.clock.callLater(1, self.xmlstream.dataReceived,
    724                              "<iq type='result' id='test'/>")
     723                                b"<iq type='result' id='test'/>")
    725724        self.clock.pump([1, 1])
    726725        self.assertFalse(self.clock.calls)
     
    868867        self.assertEquals('iq', response.name)
    869868        self.assertEquals('result', response['type'])
    870         payload = response.elements().next()
     869        payload = next(response.elements())
    871870        self.assertEqual(handler.payload, payload)
    872871
Note: See TracChangeset for help on using the changeset viewer.