def test_response_with_max_window_bits_without_client_permission(self): processor = extensions.PerMessageDeflateExtensionProcessor( common.ExtensionParameter('permessage-deflate')) processor.set_client_max_window_bits(10) response = processor.get_extension_response() self.assertIsNone(response)
def test_response_with_false_for_no_context_takeover(self): processor = extensions.PerMessageDeflateExtensionProcessor( common.ExtensionParameter('permessage-deflate')) processor.set_client_no_context_takeover(False) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual(0, len(response.get_parameters()))
def test_response_with_max_window_bits(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('client_max_window_bits', None) processor = extensions.PerMessageDeflateExtensionProcessor(parameter) processor.set_client_max_window_bits(10) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual([('client_max_window_bits', '10')], response.get_parameters())
def test_response_with_true_for_no_context_takeover(self): processor = extensions.PerMessageDeflateExtensionProcessor( common.ExtensionParameter('permessage-deflate')) processor.set_c2s_no_context_takeover(True) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual([('c2s_no_context_takeover', None)], response.get_parameters())
def test_offer_with_max_window_bits(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('server_max_window_bits', '10') processor = extensions.PerMessageDeflateExtensionProcessor(parameter) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual([('server_max_window_bits', '10')], response.get_parameters()) self.assertEqual(10, processor._rfc1979_deflater._window_bits)
def test_minimal_offer(self): processor = extensions.PerMessageDeflateExtensionProcessor( common.ExtensionParameter('permessage-deflate')) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual(0, len(response.get_parameters())) self.assertEqual(zlib.MAX_WBITS, processor._rfc1979_deflater._window_bits) self.assertFalse(processor._rfc1979_deflater._no_context_takeover)
def test_offer_with_no_context_takeover(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('server_no_context_takeover', None) processor = extensions.PerMessageDeflateExtensionProcessor(parameter) response = processor.get_extension_response() self.assertEqual('permessage-deflate', response.name()) self.assertEqual([('server_no_context_takeover', None)], response.get_parameters()) self.assertTrue(processor._rfc1979_deflater._no_context_takeover)
def test_offer_with_unknown_parameter(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('foo', 'bar') processor = extensions.PerMessageDeflateExtensionProcessor(parameter) self.assertIsNone(processor.get_extension_response())
def test_offer_with_no_context_takeover_with_value(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('server_no_context_takeover', 'foobar') processor = extensions.PerMessageDeflateExtensionProcessor(parameter) self.assertIsNone(processor.get_extension_response())
def test_offer_with_max_window_bits_without_value(self): parameter = common.ExtensionParameter('permessage-deflate') parameter.add_parameter('server_max_window_bits', None) processor = extensions.PerMessageDeflateExtensionProcessor(parameter) self.assertIsNone(processor.get_extension_response())