|
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 llama_stack_client.types.datasetio_append_rows_params import DatasetioAppendRowsParams |
@@ -843,6 +845,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: |
843 | 845 |
|
844 | 846 | assert response.http_request.headers.get("x-stainless-retry-count") == "42" |
845 | 847 |
|
| 848 | + def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 849 | + # Test that the proxy environment variables are set correctly |
| 850 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 851 | + |
| 852 | + client = DefaultHttpxClient() |
| 853 | + |
| 854 | + mounts = tuple(client._mounts.items()) |
| 855 | + assert len(mounts) == 1 |
| 856 | + assert mounts[0][0].pattern == "https://" |
| 857 | + |
| 858 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 859 | + def test_default_client_creation(self) -> None: |
| 860 | + # Ensure that the client can be initialized without any exceptions |
| 861 | + DefaultHttpxClient( |
| 862 | + verify=True, |
| 863 | + cert=None, |
| 864 | + trust_env=True, |
| 865 | + http1=True, |
| 866 | + http2=False, |
| 867 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 868 | + ) |
| 869 | + |
846 | 870 | @pytest.mark.respx(base_url=base_url) |
847 | 871 | def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
848 | 872 | # Test that the default follow_redirects=True allows following redirects |
@@ -1709,6 +1733,28 @@ async def test_main() -> None: |
1709 | 1733 |
|
1710 | 1734 | time.sleep(0.1) |
1711 | 1735 |
|
| 1736 | + async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: |
| 1737 | + # Test that the proxy environment variables are set correctly |
| 1738 | + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") |
| 1739 | + |
| 1740 | + client = DefaultAsyncHttpxClient() |
| 1741 | + |
| 1742 | + mounts = tuple(client._mounts.items()) |
| 1743 | + assert len(mounts) == 1 |
| 1744 | + assert mounts[0][0].pattern == "https://" |
| 1745 | + |
| 1746 | + @pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning") |
| 1747 | + async def test_default_client_creation(self) -> None: |
| 1748 | + # Ensure that the client can be initialized without any exceptions |
| 1749 | + DefaultAsyncHttpxClient( |
| 1750 | + verify=True, |
| 1751 | + cert=None, |
| 1752 | + trust_env=True, |
| 1753 | + http1=True, |
| 1754 | + http2=False, |
| 1755 | + limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), |
| 1756 | + ) |
| 1757 | + |
1712 | 1758 | @pytest.mark.respx(base_url=base_url) |
1713 | 1759 | async def test_follow_redirects(self, respx_mock: MockRouter) -> None: |
1714 | 1760 | # Test that the default follow_redirects=True allows following redirects |
|
0 commit comments