Exemple #1
0
 def test_encoder_set_capacity(self):
     """
     Encoder.set_capacity()
     """
     encoder = Encoder()
     encoder.set_capacity(8192)
     self.assertEqual(encoder.capacity, 8192)
Exemple #2
0
 def test_encoder_err(self):
     """
     Encoder.encode() bad headers
     """
     encoder = Encoder()
     with self.assertRaises(InvalidHeaders):
         encoder.encode_block(
             (norm('name'), norm('value'), )
         )
Exemple #3
0
    def test_encoder(self):
        """
        Encoder ok
        """
        encoder = Encoder()
        res = encoder.encode_block(((b'name', b'value'), ))
        self.assertEqual(res, b'@\x04name\x84\xee:-/')

        headers = Decoder().decode_block(res)
        self.assertEqual(headers[0].name, b'name')
        self.assertEqual(headers[0].value, b'value')
Exemple #4
0
    def test_del(self):
        """
        Encoder.__del__
        """
        encoder = Encoder()
        res = encoder.encode_block(((b'name', b'value'), ))
        self.assertEqual(res, b'@\x04name\x84\xee:-/')

        del encoder
        gc.collect()

        self.assertEqual(res, b'@\x04name\x84\xee:-/')
Exemple #5
0
 def test_encoder_example(self):
     """
     Encoder example
     """
     encoder = Encoder()
     encoded_bytes = encoder.encode_block((
         (b':method', b'GET'),
         (b':scheme', b'http'),
         (b':path', b'/'),
         (b':authority', b'www.example.com'),
     ))
     self.assertEqual(
         encoded_bytes,
         b'\x82\x86\x84A\x8c\xf1\xe3\xc2\xe5\xf2:k\xa0\xab\x90\xf4\xff'
     )