test_security_scopes.py — fastapi Source File
Architecture documentation for test_security_scopes.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e680b709_13b2_f6c0_e6f6_b4f590bae26a["test_security_scopes.py"] 0dda2280_3359_8460_301c_e98c77e78185["typing"] e680b709_13b2_f6c0_e6f6_b4f590bae26a --> 0dda2280_3359_8460_301c_e98c77e78185 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] e680b709_13b2_f6c0_e6f6_b4f590bae26a --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] e680b709_13b2_f6c0_e6f6_b4f590bae26a --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] e680b709_13b2_f6c0_e6f6_b4f590bae26a --> a7c04dee_ee23_5891_b185_47ff6bed036d style e680b709_13b2_f6c0_e6f6_b4f590bae26a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Annotated
import pytest
from fastapi import Depends, FastAPI, Security
from fastapi.testclient import TestClient
@pytest.fixture(name="call_counter")
def call_counter_fixture():
return {"count": 0}
@pytest.fixture(name="app")
def app_fixture(call_counter: dict[str, int]):
def get_db():
call_counter["count"] += 1
return f"db_{call_counter['count']}"
def get_user(db: Annotated[str, Depends(get_db)]):
return "user"
app = FastAPI()
@app.get("/")
def endpoint(
db: Annotated[str, Depends(get_db)],
user: Annotated[str, Security(get_user, scopes=["read"])],
):
return {"db": db}
return app
@pytest.fixture(name="client")
def client_fixture(app: FastAPI):
return TestClient(app)
def test_security_scopes_dependency_called_once(
client: TestClient, call_counter: dict[str, int]
):
response = client.get("/")
assert response.status_code == 200
assert call_counter["count"] == 1
Domain
Subdomains
Functions
Dependencies
- __init__.py
- pytest
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_security_scopes.py do?
test_security_scopes.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_security_scopes.py?
test_security_scopes.py defines 4 function(s): app_fixture, call_counter_fixture, client_fixture, test_security_scopes_dependency_called_once.
What does test_security_scopes.py depend on?
test_security_scopes.py imports 4 module(s): __init__.py, pytest, testclient.py, typing.
Where is test_security_scopes.py in the architecture?
test_security_scopes.py is located at tests/test_security_scopes.py (domain: FastAPI, subdomain: Responses, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free