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