Ejemplo n.º 1
0
 def test_decode_field_table_value(self):
     value = decode.field_table(self.FIELD_TBL)[1]
     for key in value.keys():
         if isinstance(value[key], float):
             self.assertAlmostEqual(round(value[key], 3),
                                    round(self.FIELD_TBL_VALUE[key], 3))
         else:
             self.assertEqual(value[key], self.FIELD_TBL_VALUE[key])
Ejemplo n.º 2
0
 def test_encode_decode_field_table_long_keys(self):
     """ Encoding and decoding a field_table with too long keys.
     """
     # second key is 126 A's + \N{PILE OF POO}
     data = {'A' * 256: 1,
             ((b'A' * 126) + b'\xf0\x9f\x92\xa9').decode('utf-8'): 2}
     encoded = encode.field_table(data)
     decoded = decode.field_table(encoded)[1]
     self.assertIn(b'A' * 128, decoded)
Ejemplo n.º 3
0
 def test_decode_field_table_data_type(self):
     self.assertIsInstance(
         decode.field_table(self.FIELD_TBL)[1], dict)
Ejemplo n.º 4
0
 def test_decode_field_table_bytes_consumed(self):
     self.assertEqual(decode.field_table(self.FIELD_TBL)[0],
                      len(self.FIELD_TBL))