| 1 |
from fastapi.testclient import TestClient |
| 2 |
|
| 3 |
from docs_src.response_change_status_code.tutorial001_py310 import app |
| 4 |
|
| 5 |
client = TestClient(app) |
| 6 |
|
| 7 |
|
| 8 |
def test_path_operation(): |
| 9 |
response = client.put("/get-or-create-task/foo") |
| 10 |
print(response.content) |
| 11 |
assert response.status_code == 200, response.text |
| 12 |
assert response.json() == "Listen to the Bar Fighters" |
| 13 |
response = client.put("/get-or-create-task/bar") |
| 14 |
assert response.status_code == 201, response.text |
| 15 |
assert response.json() == "This didn't exist before" |