test_tutorial005.py — fastapi Source File
Architecture documentation for test_tutorial005.py, a python file in the fastapi codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 132df24a_932a_c5a5_9fcb_bb38e95d696f["test_tutorial005.py"] 808d2248_38ab_f087_eb52_830ec135cadf["utils"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> 808d2248_38ab_f087_eb52_830ec135cadf 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> 83e01a9c_50a9_bec9_6f86_8e729106de01 fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] 132df24a_932a_c5a5_9fcb_bb38e95d696f --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a style 132df24a_932a_c5a5_9fcb_bb38e95d696f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import importlib
from types import ModuleType
import pytest
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from ...utils import needs_py310
@pytest.fixture(
name="mod",
params=[
pytest.param("tutorial005_py39"),
pytest.param("tutorial005_py310", marks=needs_py310),
pytest.param("tutorial005_an_py39"),
pytest.param("tutorial005_an_py310", marks=needs_py310),
],
)
def get_mod(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.security.{request.param}")
return mod
def get_access_token(
*, username="johndoe", password="secret", scope=None, client: TestClient
):
data = {"username": username, "password": password}
if scope:
data["scope"] = scope
response = client.post("/token", data=data)
content = response.json()
access_token = content.get("access_token")
return access_token
def test_login(mod: ModuleType):
client = TestClient(mod.app)
response = client.post("/token", data={"username": "johndoe", "password": "secret"})
assert response.status_code == 200, response.text
content = response.json()
assert "access_token" in content
assert content["token_type"] == "bearer"
def test_login_incorrect_password(mod: ModuleType):
client = TestClient(mod.app)
response = client.post(
"/token", data={"username": "johndoe", "password": "incorrect"}
)
assert response.status_code == 400, response.text
assert response.json() == {"detail": "Incorrect username or password"}
def test_login_incorrect_username(mod: ModuleType):
client = TestClient(mod.app)
response = client.post("/token", data={"username": "foo", "password": "secret"})
assert response.status_code == 400, response.text
assert response.json() == {"detail": "Incorrect username or password"}
// ... (357 more lines)
Domain
Subdomains
Functions
- get_access_token()
- get_mod()
- test_create_access_token()
- test_get_password_hash()
- test_incorrect_token()
- test_incorrect_token_type()
- test_login()
- test_login_incorrect_password()
- test_login_incorrect_username()
- test_no_token()
- test_openapi_schema()
- test_read_items()
- test_read_system_status()
- test_read_system_status_no_token()
- test_token()
- test_token_inactive_user()
- test_token_no_scope()
- test_token_no_sub()
- test_token_no_username()
- test_token_nonexistent_user()
- test_verify_password()
Dependencies
- importlib
- inline_snapshot
- pytest
- testclient.py
- types
- utils
Source
Frequently Asked Questions
What does test_tutorial005.py do?
test_tutorial005.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_tutorial005.py?
test_tutorial005.py defines 21 function(s): get_access_token, get_mod, test_create_access_token, test_get_password_hash, test_incorrect_token, test_incorrect_token_type, test_login, test_login_incorrect_password, test_login_incorrect_username, test_no_token, and 11 more.
What does test_tutorial005.py depend on?
test_tutorial005.py imports 6 module(s): importlib, inline_snapshot, pytest, testclient.py, types, utils.
Where is test_tutorial005.py in the architecture?
test_tutorial005.py is located at tests/test_tutorial/test_security/test_tutorial005.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_security).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free