def setUp(self): self._protocol = Protocol('TestProtocol') self._protocol.add(UInt(2, 'msgId', 5)) self._protocol.add(UInt(2, 'length', None)) self._protocol.add(PDU('length-4')) self.tmp = MessageTemplate('FooRequest', self._protocol, {}) self.tmp.add(UInt(2, 'field_1', 1)) self.tmp.add(UInt(2, 'field_2', 2))
def setUp(self): self._protocol = Protocol('TestProtocol', little_endian=True) self._protocol.add(UInt(2, 'msgId', 5)) self._protocol.add(UInt(2, 'length', None)) self._protocol.add(PDU('length-4')) self.tmp = MessageTemplate('FooRequest', self._protocol, {}) self.tmp.add(UInt(2, 'field_1', '0xcafe')) self.tmp.add(UInt(2, 'field_2', '0xbabe'))
def setUp(self): self._protocol = Protocol('TestProtocol') self._protocol.add(UInt(2, 'msgId', 5)) self._protocol.add(UInt(2, 'length', None)) self._protocol.add(PDU('length-4')) self.tmp = MessageTemplate('FooRequest', self._protocol, {}) self.tmp.add(UInt(2, 'field_1', '0xcafe')) self.tmp.add(UInt(2, 'field_2', '0xbabe')) self.example = self.tmp.encode({}, {})
def test_access_struct(self): self._protocol = Protocol('TestProtocol') self._protocol.add(UInt(2, 'msgId', 5)) self._protocol.add(UInt(2, 'length', None)) self._protocol.add(PDU('length-4')) self.tmp = MessageTemplate('StructuredRequest', self._protocol, {}) struct = get_pair() self.tmp.add(struct) msg = self.tmp.encode({}, {}) self.assertEquals(msg.pair.first.int, 1)
def setUp(self): self._protocol = Protocol('Test')
def _get_template(): protocol = Protocol('Test') protocol.add(UInt(1, 'id', 1)) protocol.add(UInt(2, 'length', None)) protocol.add(PDU('length-2')) return protocol
def setUp(self): self._protocol = Protocol('TestProtocol') self._protocol.add(UInt(2, 'msgId', 5)) self._protocol.add(UInt(2, 'length', None)) self._protocol.add(PDU('length-4'))