Introduction to FastAPI
Matt Eckerle
Software and Data Engineering Leader
def test_read():
response = client.get("/items/1")
assert response.status_code == 200
def test_delete_then_read():
response = client.delete("/items/1")
assert response.status_code == 200
response = client.get("/items/1")
assert response.status_code == 404
requests
import requests
ENDPOINT = "http://localhost:8000/items"
# Create item "rock"
r = requests.post(ENDPOINT, json={"name": "rock"})
assert r.status_code == 200
# Get item rock
r = requests.get(ENDPOINT, json={"name": "rock"})
assert r.status_code == 200
Introduction to FastAPI