Create async client for use in test cases. Args: trusted_hosts: trusted_hosts for proxy middleware client: transport client to use
(
trusted_hosts: str | list[str],
client: tuple[str, int] = ("127.0.0.1", 123),
)
| 41 | |
| 42 | |
| 43 | def make_httpx_client( |
| 44 | trusted_hosts: str | list[str], |
| 45 | client: tuple[str, int] = ("127.0.0.1", 123), |
| 46 | ) -> httpx.AsyncClient: |
| 47 | """Create async client for use in test cases. |
| 48 | |
| 49 | Args: |
| 50 | trusted_hosts: trusted_hosts for proxy middleware |
| 51 | client: transport client to use |
| 52 | """ |
| 53 | |
| 54 | app = ProxyHeadersMiddleware(default_app, trusted_hosts) |
| 55 | transport = httpx.ASGITransport(app=app, client=client) # type: ignore |
| 56 | return httpx.AsyncClient(transport=transport, base_url="http://testserver") |
| 57 | |
| 58 | |
| 59 | # Note: we vary the format here to also test some of the functionality |
no test coverage detected