aio_microservice.core.testing

Attributes

Classes

TestHttpClient

An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,

Module Contents

aio_microservice.core.testing.ServiceT
class aio_microservice.core.testing.TestHttpClient(service)[source]

Bases: litestar.testing.AsyncTestClient[litestar.Litestar]

An asynchronous HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.

It can be shared between tasks.

Usage:

`python >>> async with httpx.AsyncClient() as client: >>>     response = await client.get('https://example.org') `

Parameters:

  • auth - (optional) An authentication class to use when sending

requests. * params - (optional) Query parameters to include in request URLs, as a string, dictionary, or sequence of two-tuples. * headers - (optional) Dictionary of HTTP headers to include when sending requests. * cookies - (optional) Dictionary of Cookie items to include when sending requests. * verify - (optional) SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either True (default CA bundle), a path to an SSL certificate file, an ssl.SSLContext, or False (which will disable verification). * cert - (optional) An SSL certificate used by the requested host to authenticate the client. Either a path to an SSL certificate file, or two-tuple of (certificate file, key file), or a three-tuple of (certificate file, key file, password). * http2 - (optional) A boolean indicating if HTTP/2 support should be enabled. Defaults to False. * proxy - (optional) A proxy URL where all the traffic should be routed. * proxies - (optional) A dictionary mapping HTTP protocols to proxy URLs. * timeout - (optional) The timeout configuration to use when sending requests. * limits - (optional) The limits configuration to use. * max_redirects - (optional) The maximum number of redirect responses that should be followed. * base_url - (optional) A URL to use as the base when building request URLs. * transport - (optional) A transport class to use for sending requests over the network. * app - (optional) An ASGI application to send requests to, rather than sending actual network requests. * trust_env - (optional) Enables or disables usage of environment variables for configuration. * default_encoding - (optional) The default encoding to use for decoding response text, if no charset information is included in a response Content-Type header. Set to a callable for automatic character set detection. Default: “utf-8”.

Parameters:

service (ServiceT)