|
31 | 31 | DEFAULT_TIMEOUT, |
32 | 32 | HTTPX_DEFAULT_TIMEOUT, |
33 | 33 | BaseClient, |
| 34 | + DefaultHttpxClient, |
| 35 | + DefaultAsyncHttpxClient, |
34 | 36 | make_request_options, |
35 | 37 | ) |
36 | 38 | from cloudflare.types.zones.zone_create_params import ZoneCreateParams |
@@ -1012,6 +1014,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
1012 | 1014 |
|
1013 | 1015 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
1014 | 1016 |
|
| 1017 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1018 | + # Test that the proxy environment variables are set correctly |
| 1019 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1020 | + |
| 1021 | + client = DefaultHttpxClient() |
| 1022 | + |
| 1023 | + mounts = tuple(client._mounts.items()) |
| 1024 | + assert len(mounts) == 1 |
| 1025 | + assert mounts[0][0].pattern == "https://" |
| 1026 | + |
| 1027 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1028 | + def test_default_client_creation(self) -> None: |
| 1029 | + # Ensure that the client can be initialized without any exceptions |
| 1030 | + DefaultHttpxClient( |
| 1031 | + verify=True, |
| 1032 | + cert=None, |
| 1033 | + trust_env=True, |
| 1034 | + http1=True, |
| 1035 | + http2=False, |
| 1036 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1037 | + ) |
| 1038 | + |
1015 | 1039 | @pytest.mark.respx(base_url=base_url) |
1016 | 1040 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1017 | 1041 | # Test that the default follow_redirects=True allows following redirects |
@@ -1966,6 +1990,28 @@ async def test_main() -> None: |
1966 | 1990 |
|
1967 | 1991 | time.sleep(0.1) |
1968 | 1992 |
|
| 1993 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1994 | + # Test that the proxy environment variables are set correctly |
| 1995 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1996 | + |
| 1997 | + client = DefaultAsyncHttpxClient() |
| 1998 | + |
| 1999 | + mounts = tuple(client._mounts.items()) |
| 2000 | + assert len(mounts) == 1 |
| 2001 | + assert mounts[0][0].pattern == "https://" |
| 2002 | + |
| 2003 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 2004 | + async def test_default_client_creation(self) -> None: |
| 2005 | + # Ensure that the client can be initialized without any exceptions |
| 2006 | + DefaultAsyncHttpxClient( |
| 2007 | + verify=True, |
| 2008 | + cert=None, |
| 2009 | + trust_env=True, |
| 2010 | + http1=True, |
| 2011 | + http2=False, |
| 2012 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 2013 | + ) |
| 2014 | + |
1969 | 2015 | @pytest.mark.respx(base_url=base_url) |
1970 | 2016 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1971 | 2017 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments