def test_pack_byte_from_json(self): doc = { 'код ответа ОФД': 42, } self.assertEqual( struct.pack('<HHc', 1022, 1, ofd.Byte('', '').pack(42)), ofd.protocol.pack_json(doc))
def test_unpack_byte(self): self.assertEqual(3, ofd.Byte(name='', desc='').unpack(b'\x03'))
def test_unpack_byte_throws_on_length_mismatch(self): with self.assertRaises(Exception): ofd.Byte(name='', desc='').unpack('\x03\x04')
def test_pack_byte(self): self.assertEqual(b'\x03', ofd.Byte(name='', desc='').pack(3))