I am writing unittest for Django-rest-framework API endpoints. In version 3.5, they have added RequestsClient(). Documentation says -
Rather than sending any HTTP requests to the network, this interface will coerce all outgoing requests into WSGI, and call into your application directly.
From my understanding, I think RequestsClient() is useful for the network request from different servers. Not sure if it has any advantage in the same server? Also Is there any advantage of using RequestsClient() over APIClient() ?
Is there any advantage of using RequestsClient() over APIClient()
This is a higher lever of test. RequestsClient
will test against your stack from the WSGI layer which APIClient bypasses.
This also means that tests that uses authentication or CSRF will be looking more like what happens with real requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With