示例#1
0
 def _pubcomp(self, dl):
     compl = []
     for i in range(0, len(dl)):
         comp= PUBCOMP()
         comp.msgId = dl[i].msgId
         compl.append(comp)
     encoded = bytearray()
     for rec in compl:
         encoded.extend(comp.encode())
     self.protocol.dataReceived(encoded)
     self.transport.clear()
     for i in range(0, len(dl)):
         self.assertEqual(dl[i].msgId, self.successResultOf(dl[i]))
示例#2
0
 def _pubcomp(self, dl):
     compl = []
     for i in range(0, len(dl)):
         comp = PUBCOMP()
         comp.msgId = dl[i].msgId
         compl.append(comp)
     encoded = bytearray()
     for comp in compl:
         encoded.extend(comp.encode())
     self.protocol.dataReceived(encoded)
     self.transport.clear()
     for i in range(0, len(dl)):
         self.assertEqual(dl[i].msgId, self.successResultOf(dl[i]))
示例#3
0
    def test_PUBCOMP_encdec(self):
        request = PUBCOMP()
        response = PUBCOMP()
        request.msgId = 30002

        response.decode(request.encode())
        self.assertEqual(request.msgId, response.msgId)
示例#4
0
 def test_publish_single_qos2(self):
     self._connect()
     d = self.protocol.publish(topic="foo/bar/baz1",
                               qos=2,
                               message="hello world 2")
     self.assertEqual(len(self.protocol.factory.windowPublish[self.addr]),
                      1)
     self.assertEqual(
         len(self.protocol.factory.windowPubRelease[self.addr]), 0)
     self.transport.clear()
     ack = PUBREC()
     ack.msgId = d.msgId
     self.protocol.dataReceived(ack.encode())
     self.transport.clear()
     self.assertEqual(len(self.protocol.factory.windowPublish[self.addr]),
                      0)
     self.assertEqual(
         len(self.protocol.factory.windowPubRelease[self.addr]), 1)
     ack = PUBCOMP()
     ack.msgId = d.msgId
     self.protocol.dataReceived(ack.encode())
     self.assertEqual(len(self.protocol.factory.windowPublish[self.addr]),
                      0)
     self.assertEqual(
         len(self.protocol.factory.windowPubRelease[self.addr]), 0)
     self.assertEqual(ack.msgId, self.successResultOf(d))
示例#5
0
 def test_PUBCOMP_encdec(self):
     request  = PUBCOMP()
     response = PUBCOMP()
     request.msgId = 30002
     
     response.decode(request.encode())
     self.assertEqual(request.msgId, response.msgId)