Test client and case suite¶
Async-aware test utilities for restflow async views. See the Testing guide for picking the right base class and writing signal-driven cache invalidation tests.
AsyncAPIClient ¶
Bases: AsyncClient
Async test client for restflow's AsyncAPIView and AsyncViewSet.
Drop-in for Django's AsyncClient and DRF's APIClient. Adds
DRF-style format encoding (json by default), force_authenticate(),
and credentials() so async views can be exercised end-to-end.
credentials ¶
Set headers used on every outgoing request. Keys must start with HTTP_ or CONTENT_ to mirror Django's WSGI environ convention.
force_authenticate ¶
Forcibly authenticate outgoing requests with the given user or token.
request
async
¶
Make a generic async request, merging stored credentials into headers.
post
async
¶
Send a POST request with DRF-style format encoding.
put
async
¶
Send a PUT request with DRF-style format encoding.
patch
async
¶
Send a PATCH request with DRF-style format encoding.
delete
async
¶
Send a DELETE request with DRF-style format encoding.
options
async
¶
Send an OPTIONS request with DRF-style format encoding.
AsyncAPIRequestFactory ¶
Bases: AsyncRequestFactory
Builds raw ASGI requests for tests that bind a request directly to a view instance and await dispatch.
Mirrors DRF's APIRequestFactory but produces ASGI-style requests
suitable for await view.dispatch(request).
post ¶
Construct a POST request with DRF-style format encoding.
put ¶
Construct a PUT request with DRF-style format encoding.
patch ¶
Construct a PATCH request with DRF-style format encoding.
delete ¶
Construct a DELETE request with DRF-style format encoding.
options ¶
Construct an OPTIONS request with DRF-style format encoding.
request ¶
Construct a generic request, marking CSRF checks per the factory setting.
force_authenticate ¶
Force-authenticate a request, bypassing the authenticator chain.
AsyncAPISimpleTestCase ¶
Bases: SimpleTestCase
Async-shaped SimpleTestCase wired up with AsyncAPIClient.
AsyncAPITestCase ¶
Bases: TestCase
Async-shaped TestCase wired up with AsyncAPIClient.
AsyncAPITransactionTestCase ¶
Bases: TransactionTestCase
Async-shaped TransactionTestCase wired up with AsyncAPIClient.
AsyncAPILiveServerTestCase ¶
Bases: LiveServerTestCase
Async-shaped LiveServerTestCase wired up with AsyncAPIClient.