Complete the code to import the TestClient from FastAPI's testing module.
from fastapi.testclient import [1]
The TestClient is imported from fastapi.testclient to test FastAPI apps.
Complete the code to create a TestClient instance for the FastAPI app named 'app'.
client = [1](app)You create a TestClient instance by passing the FastAPI app object to it.
Fix the error in the code to send a GET request to '/' using the TestClient instance named 'client'.
response = client.[1]("/")
To send a GET request, use the get method on the TestClient instance.
Fill both blanks to check if the response status code is 200 and the response JSON has a key 'message'.
assert response.status_code == [1] assert 'message' [2] response.json()
Status code 200 means success. The 'in' keyword checks if 'message' is a key in the JSON response.
Fill all three blanks to send a POST request with JSON data {'name': 'Alice'} and check if the response JSON contains the same name.
response = client.[1]("/users", json=[2]) assert response.json().get('name') == [3]
Use post to send data. The JSON data is a dictionary with name 'Alice'. The assertion checks the response JSON's 'name' equals 'Alice'.