from rest_framework.test import APIClient client = APIClient() # Make a DELETE request to /api/books/1/ response = client.delete('/api/books/1/') # Check the response status code assert response.status_code == 204
client = APIClient() # Make a GET request to /api/courses/ with param "category=math" response = client.get('/api/courses/', {'category': 'math'}) # Check the response status code and response data assert response.status_code == 200 assert len(response.data) == 2In this case, the client sends a `GET` request to the `/api/courses/` endpoint with a query parameter `category=math`. The code asserts that the server returns a `200 OK` response and the response data contains 2 items. The package library used in this code is Django REST Framework.