|
@@ -1411,6 +1411,39 @@ class HttpGitClientTests(TestCase):
|
|
|
self.assertEqual(pack_data[4:8], b"\x00\x00\x00\x02") # version 2
|
|
|
self.assertEqual(pack_data[8:12], b"\x00\x00\x00\x01") # 1 object
|
|
|
|
|
|
+ def test_timeout_configuration(self) -> None:
|
|
|
+ """Test that timeout parameter is properly configured."""
|
|
|
+ url = "https://github.com/jelmer/dulwich"
|
|
|
+ timeout = 30
|
|
|
+
|
|
|
+ c = HttpGitClient(url, timeout=timeout)
|
|
|
+ self.assertEqual(c._timeout, timeout)
|
|
|
+
|
|
|
+ def test_timeout_from_config(self) -> None:
|
|
|
+ """Test that timeout can be configured via git config."""
|
|
|
+ from dulwich.config import ConfigDict
|
|
|
+
|
|
|
+ url = "https://github.com/jelmer/dulwich"
|
|
|
+ config = ConfigDict()
|
|
|
+ config.set((b"http",), b"timeout", b"25")
|
|
|
+
|
|
|
+ c = HttpGitClient(url, config=config)
|
|
|
+ # The timeout should be set on the pool manager
|
|
|
+ # Since we can't easily access the timeout from the pool manager,
|
|
|
+ # we just verify the client was created successfully
|
|
|
+ self.assertIsNotNone(c.pool_manager)
|
|
|
+
|
|
|
+ def test_timeout_parameter_precedence(self) -> None:
|
|
|
+ """Test that explicit timeout parameter takes precedence over config."""
|
|
|
+ from dulwich.config import ConfigDict
|
|
|
+
|
|
|
+ url = "https://github.com/jelmer/dulwich"
|
|
|
+ config = ConfigDict()
|
|
|
+ config.set((b"http",), b"timeout", b"25")
|
|
|
+
|
|
|
+ c = HttpGitClient(url, config=config, timeout=15)
|
|
|
+ self.assertEqual(c._timeout, 15)
|
|
|
+
|
|
|
|
|
|
class TCPGitClientTests(TestCase):
|
|
|
def test_get_url(self) -> None:
|
|
@@ -1670,6 +1703,32 @@ class DefaultUrllib3ManagerTest(TestCase):
|
|
|
manager = default_urllib3_manager(config=None, cert_reqs="CERT_NONE")
|
|
|
self.assertEqual(manager.connection_pool_kw["cert_reqs"], "CERT_NONE")
|
|
|
|
|
|
+ def test_timeout_parameter(self) -> None:
|
|
|
+ """Test that timeout parameter is passed to urllib3 manager."""
|
|
|
+ timeout = 30
|
|
|
+ manager = default_urllib3_manager(config=None, timeout=timeout)
|
|
|
+ self.assertEqual(manager.connection_pool_kw["timeout"], timeout)
|
|
|
+
|
|
|
+ def test_timeout_from_config(self) -> None:
|
|
|
+ """Test that timeout can be configured via git config."""
|
|
|
+ from dulwich.config import ConfigDict
|
|
|
+
|
|
|
+ config = ConfigDict()
|
|
|
+ config.set((b"http",), b"timeout", b"25")
|
|
|
+
|
|
|
+ manager = default_urllib3_manager(config=config)
|
|
|
+ self.assertEqual(manager.connection_pool_kw["timeout"], 25)
|
|
|
+
|
|
|
+ def test_timeout_parameter_precedence(self) -> None:
|
|
|
+ """Test that explicit timeout parameter takes precedence over config."""
|
|
|
+ from dulwich.config import ConfigDict
|
|
|
+
|
|
|
+ config = ConfigDict()
|
|
|
+ config.set((b"http",), b"timeout", b"25")
|
|
|
+
|
|
|
+ manager = default_urllib3_manager(config=config, timeout=15)
|
|
|
+ self.assertEqual(manager.connection_pool_kw["timeout"], 15)
|
|
|
+
|
|
|
|
|
|
class SubprocessSSHVendorTests(TestCase):
|
|
|
def setUp(self) -> None:
|