def test_serialize_deserialize_simple(self):
     data = {
         1943: "bike trip",
         1986: 426,
         1: bytes([0xAC, 0xAB]),
         2: bytearray([0xFE, 0xED, 0xBA, 0xDB, 0xEE, 0xF0]),
     }
     m = Metadata(data.items())
     m2 = Metadata.deserialize(m.serialize())
     self.assertDictEqual(data, m2)
 def test_serialize_list(self):
     data = {
         997: [
             "an example",
             321,
             "of multitype".encode("ascii"),
             ["nested", "list", 0],
         ]
     }
     m = Metadata(data.items())
     d = m.serialize()
     self.assertEqual(len(d), 1)
 def test_serialize_deserialize_list(self):
     data = {
         997: [
             "an example",
             321,
             "of multitype".encode("ascii"),
             ["nested", "list", 0],
         ]
     }
     m = Metadata(data.items())
     m2 = Metadata.deserialize(m.serialize())
     self.assertDictEqual(data, m2)
     self.assertEqual(data[997], m2[997])
 def test_serialize_simple(self):
     data = {
         1943: "bike trip",
         1986: 426,
         1: bytes([0xAC, 0xAB]),
         2: bytearray([0xFE, 0xED, 0xBA, 0xDB, 0xEE, 0xF0]),
     }
     m = Metadata(data.items())
     d = m.serialize()
     self.assertEqual(len(d), 4)
     self.assertIn("1", d)
     self.assertIn("2", d)
     self.assertIn("1943", d)
     self.assertIn("1986", d)
     self.assertDictEqual(d["1"], {"bytes": "acab"})
     self.assertDictEqual(d["2"], {"bytes": "feedbadbeef0"})
     self.assertDictEqual(d["1943"], {"string": "bike trip"})
     self.assertDictEqual(d["1986"], {"int": 426})