def test_connection_from_context_strict_param( self, connection_from_pool_key: mock.MagicMock ) -> None: p = PoolManager() context = { "scheme": "http", "host": "example.com", "port": 8080, "strict": True, } with pytest.warns(DeprecationWarning) as records: p.connection_from_context(context) msg = ( "The 'strict' parameter is no longer needed on Python 3+. " "This will raise an error in urllib3 v3.0.0." ) record = records[0] assert isinstance(record.message, Warning) assert record.message.args[0] == msg _, kwargs = connection_from_pool_key.call_args assert kwargs["request_context"] == { "scheme": "http", "host": "example.com", "port": 8080, }
def test_http_connection_from_context_case_insensitive(self): """Assert scheme case is ignored when getting the https key class.""" p = PoolManager() context = {'scheme': 'http', 'host': 'example.com', 'port': '8080'} other_context = {'scheme': 'HTTP', 'host': 'EXAMPLE.COM', 'port': '8080'} pool = p.connection_from_context(context) other_pool = p.connection_from_context(other_context) assert 1 == len(p.pools) assert pool is other_pool assert all(isinstance(key, PoolKey) for key in p.pools.keys())
def test_http_connection_from_context_case_insensitive(self): """Assert scheme case is ignored when getting the https key class.""" p = PoolManager() context = {"scheme": "http", "host": "example.com", "port": "8080"} other_context = {"scheme": "HTTP", "host": "EXAMPLE.COM", "port": "8080"} pool = p.connection_from_context(context) other_pool = p.connection_from_context(other_context) assert 1 == len(p.pools) assert pool is other_pool assert all(isinstance(key, PoolKey) for key in p.pools.keys())
def test_http_connection_from_context_case_insensitive(self): """Assert scheme case is ignored when getting the https key class.""" p = PoolManager() self.addCleanup(p.clear) context = {'scheme': 'http', 'host': 'example.com', 'port': '8080'} other_context = {'scheme': 'HTTP', 'host': 'EXAMPLE.COM', 'port': '8080'} pool = p.connection_from_context(context) other_pool = p.connection_from_context(other_context) self.assertEqual(1, len(p.pools)) self.assertTrue(pool is other_pool) self.assertTrue(all(isinstance(key, HTTPPoolKey) for key in p.pools.keys()))
def test_https_connection_from_context_case_insensitive(self): """Assert scheme case is ignored when getting the https key class.""" p = PoolManager() self.addCleanup(p.clear) context = {'scheme': 'https', 'host': 'example.com', 'port': '443'} other_context = {'scheme': 'HTTPS', 'host': 'EXAMPLE.COM', 'port': '443'} pool = p.connection_from_context(context) other_pool = p.connection_from_context(other_context) self.assertEqual(1, len(p.pools)) self.assertTrue(pool is other_pool) self.assertTrue(all(isinstance(key, PoolKey) for key in p.pools.keys()))