def test_CONNACK_encdec(self): request = CONNACK() response = CONNACK() request.session = True request.resultCode = 2 response.decode(request.encode()) self.assertEqual(request.encoded[0], response.encoded[0]) self.assertEqual(request.session, response.session) self.assertEqual(request.resultCode, response.resultCode)
def _connect(self, cleanStart=True): ''' Go to connected state ''' ack = CONNACK() ack.session = False ack.resultCode = 0 ack.encode() self.protocol.connect("TwistedMQTT-pubsubs", keepalive=0, cleanStart=cleanStart, version=v31) self.transport.clear() self.protocol.dataReceived(ack.encoded)
def test_connect(self): self.CONNACK = CONNACK() self.CONNACK.session = False self.CONNACK.resultCode = 0 self.CONNACK.encode() d = self.protocol.connect("TwistedMQTT-pub", keepalive=0, version=v31) self.transport.clear() self.assertEqual(self.protocol.state, self.protocol.CONNECTING) self.protocol.dataReceived(self.CONNACK.encoded) self.assertEqual(self.protocol.state, self.protocol.CONNECTED) self.assertEqual(self.CONNACK.session, self.successResultOf(d))