test_tutorial001.py — fastapi Source File
Architecture documentation for test_tutorial001.py, a python file in the fastapi codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR a53c9491_3c09_f5bb_f708_b9589ee8c416["test_tutorial001.py"] a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] a53c9491_3c09_f5bb_f708_b9589ee8c416 --> a7c04dee_ee23_5891_b185_47ff6bed036d 92601088_579a_8438_30e8_c0dce39c2552["tutorial001_py39.py"] a53c9491_3c09_f5bb_f708_b9589ee8c416 --> 92601088_579a_8438_30e8_c0dce39c2552 style a53c9491_3c09_f5bb_f708_b9589ee8c416 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from fastapi.testclient import TestClient
from docs_src.cors.tutorial001_py39 import app
def test_cors():
client = TestClient(app)
# Test pre-flight response
headers = {
"Origin": "https://localhost.tiangolo.com",
"Access-Control-Request-Method": "GET",
"Access-Control-Request-Headers": "X-Example",
}
response = client.options("/", headers=headers)
assert response.status_code == 200, response.text
assert response.text == "OK"
assert (
response.headers["access-control-allow-origin"]
== "https://localhost.tiangolo.com"
)
assert response.headers["access-control-allow-headers"] == "X-Example"
# Test standard response
headers = {"Origin": "https://localhost.tiangolo.com"}
response = client.get("/", headers=headers)
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert (
response.headers["access-control-allow-origin"]
== "https://localhost.tiangolo.com"
)
# Test non-CORS response
response = client.get("/")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert "access-control-allow-origin" not in response.headers
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does test_tutorial001.py do?
test_tutorial001.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_tutorial001.py?
test_tutorial001.py defines 1 function(s): test_cors.
What does test_tutorial001.py depend on?
test_tutorial001.py imports 2 module(s): testclient.py, tutorial001_py39.py.
Where is test_tutorial001.py in the architecture?
test_tutorial001.py is located at tests/test_tutorial/test_cors/test_tutorial001.py (domain: FastAPI, subdomain: Routing, directory: tests/test_tutorial/test_cors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free