Пример #1
0
 def testBitReadBaseRequestEncoding(self):
     ''' Test basic bit message encoding/decoding '''
     for i in range(20):
         handle = ReadBitsRequestBase(i, i)
         result = struct.pack('>HH', i, i)
         self.assertEqual(handle.encode(), result)
         handle.decode(result)
         self.assertEqual((handle.address, handle.count), (i, i))
Пример #2
0
 def testBitReadBaseRequestEncoding(self):
     ''' Test basic bit message encoding/decoding '''
     for i in range(20):
         handle = ReadBitsRequestBase(i, i)
         result = struct.pack('>HH',i, i)
         self.assertEqual(handle.encode(), result)
         handle.decode(result)
         self.assertEqual((handle.address, handle.count), (i,i))
Пример #3
0
 def testBitReadBaseRequests(self):
     ''' Test bit read request encoding '''
     messages = {
         ReadBitsRequestBase(12, 14): b'\x00\x0c\x00\x0e',
         ReadBitsResponseBase([1, 0, 1, 1, 0]): b'\x01\x0d'
     }
     for request, expected in iteritems(messages):
         self.assertEqual(request.encode(), expected)
Пример #4
0
 def testReadBitBaseClassMethods(self):
     ''' Test basic bit message encoding/decoding '''
     handle = ReadBitsRequestBase(1, 1)
     msg = "ReadBitRequest(1,1)"
     self.assertEqual(msg, str(handle))
     handle = ReadBitsResponseBase([1, 1])
     msg = "ReadBitResponse(2)"
     self.assertEqual(msg, str(handle))