|
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 openlayer.types.inference_pipelines.data_stream_params import DataStreamParams
|
@@ -921,6 +923,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
|
921 | 923 |
|
922 | 924 | assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
923 | 925 |
|
| 926 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 927 | + # Test that the proxy environment variables are set correctly |
| 928 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 929 | + |
| 930 | + client = DefaultHttpxClient() |
| 931 | + |
| 932 | + mounts = tuple(client._mounts.items()) |
| 933 | + assert len(mounts) == 1 |
| 934 | + assert mounts[0][0].pattern == "https://" |
| 935 | + |
| 936 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 937 | + def test_default_client_creation(self) -> None: |
| 938 | + # Ensure that the client can be initialized without any exceptions |
| 939 | + DefaultHttpxClient( |
| 940 | + verify=True, |
| 941 | + cert=None, |
| 942 | + trust_env=True, |
| 943 | + http1=True, |
| 944 | + http2=False, |
| 945 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 946 | + ) |
| 947 | + |
924 | 948 | @pytest.mark.respx(base_url=base_url)
|
925 | 949 | def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
926 | 950 | # Test that the default follow_redirects=True allows following redirects
|
@@ -1875,6 +1899,28 @@ async def test_main() -> None:
|
1875 | 1899 |
|
1876 | 1900 | time.sleep(0.1)
|
1877 | 1901 |
|
| 1902 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1903 | + # Test that the proxy environment variables are set correctly |
| 1904 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1905 | + |
| 1906 | + client = DefaultAsyncHttpxClient() |
| 1907 | + |
| 1908 | + mounts = tuple(client._mounts.items()) |
| 1909 | + assert len(mounts) == 1 |
| 1910 | + assert mounts[0][0].pattern == "https://" |
| 1911 | + |
| 1912 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1913 | + async def test_default_client_creation(self) -> None: |
| 1914 | + # Ensure that the client can be initialized without any exceptions |
| 1915 | + DefaultAsyncHttpxClient( |
| 1916 | + verify=True, |
| 1917 | + cert=None, |
| 1918 | + trust_env=True, |
| 1919 | + http1=True, |
| 1920 | + http2=False, |
| 1921 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1922 | + ) |
| 1923 | + |
1878 | 1924 | @pytest.mark.respx(base_url=base_url)
|
1879 | 1925 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None:
|
1880 | 1926 | # Test that the default follow_redirects=True allows following redirects
|
|
0 commit comments