Exemplo n.º 1
0
 def test_bad_deserialize(self) -> None:
     with self.assertRaises(Error):
         deserialize(easy, b"", protocol=Protocol.JSON)
     with self.assertRaises(Error):
         deserialize(easy, b"\x05AAAAAAAA")
     with self.assertRaises(Error):
         deserialize(easy, b"\x02\xDE\xAD\xBE\xEF", protocol=Protocol.BINARY)
     with self.assertRaises(BufferError):
         deserialize_from_header(easy, b"\x02\xDE\xAD\xBE\xEF")
     with self.assertRaises(Error):
         control = easy(val=5, val_list=[4, 3, 2, 1])
         buf = serialize_with_header(control, transform=Transform.ZSTD_TRANSFORM)
         newBytes = bytearray(buf)
         newBytes[4] += 1
         deserialize_from_header(easy, bytes(newBytes))
Exemplo n.º 2
0
 def test_with_header_iobuf_binary(self) -> None:
     control = easy(val=6, val_list=[5, 4, 3, 2, 1])
     iobuf = serialize_with_header_iobuf(
         control, protocol=Protocol.BINARY, transform=Transform.ZLIB_TRANSFORM
     )
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)
Exemplo n.º 3
0
 def test_with_header_binary(self) -> None:
     control = easy(val=6, val_list=[5, 4, 3, 2, 1])
     iobuf = serialize_with_header(
         control, protocol=Protocol.BINARY, transform=Transform.ZLIB_TRANSFORM
     )
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)
Exemplo n.º 4
0
 def test_with_header_iobuf_json(self) -> None:
     control = easy(val=4, val_list=[3, 2, 1])
     iobuf = serialize_with_header_iobuf(control, protocol=Protocol.JSON)
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)
Exemplo n.º 5
0
 def test_with_header_iobuf(self) -> None:
     control = easy(val=5, val_list=[4, 3, 2, 1])
     iobuf = serialize_with_header_iobuf(control, transform=Transform.ZSTD_TRANSFORM)
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)
Exemplo n.º 6
0
 def test_with_header_json(self) -> None:
     control = easy(val=4, val_list=[3, 2, 1])
     iobuf = serialize_with_header(control, protocol=Protocol.JSON)
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)
Exemplo n.º 7
0
 def test_with_header(self) -> None:
     control = easy(val=5, val_list=[4, 3, 2, 1])
     iobuf = serialize_with_header(control, transform=Transform.ZSTD_TRANSFORM)
     decoded = deserialize_from_header(easy, iobuf)
     self.assertEqual(control, decoded)