test_webhooks_security.py — fastapi Source File
Architecture documentation for test_webhooks_security.py, a python file in the fastapi codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 264b13a6_44a6_f021_eb11_326f5a115ba2["test_webhooks_security.py"] e973e384_8276_b242_eb98_1c0b79a84e68["datetime"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> e973e384_8276_b242_eb98_1c0b79a84e68 0dda2280_3359_8460_301c_e98c77e78185["typing"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 35c4ea20_c454_5afd_6cda_f0818bbcc650["__init__.py"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> 35c4ea20_c454_5afd_6cda_f0818bbcc650 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] 264b13a6_44a6_f021_eb11_326f5a115ba2 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style 264b13a6_44a6_f021_eb11_326f5a115ba2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from datetime import datetime
from typing import Annotated
from fastapi import FastAPI, Security
from fastapi.security import HTTPBearer
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
bearer_scheme = HTTPBearer()
class Subscription(BaseModel):
username: str
monthly_fee: float
start_date: datetime
@app.webhooks.post("new-subscription")
def new_subscription(
body: Subscription, token: Annotated[str, Security(bearer_scheme)]
):
"""
When a new user subscribes to your service we'll send you a POST request with this
data to the URL that you register for the event `new-subscription` in the dashboard.
"""
client = TestClient(app)
def test_dummy_webhook():
# Just for coverage
new_subscription(body={}, token="Bearer 123")
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {},
"webhooks": {
"new-subscription": {
"post": {
"summary": "New Subscription",
"description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.",
"operationId": "new_subscriptionnew_subscription_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Subscription"
}
}
},
// ... (75 more lines)
Domain
Subdomains
Classes
Dependencies
- __init__.py
- __init__.py
- datetime
- inline_snapshot
- pydantic
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_webhooks_security.py do?
test_webhooks_security.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_webhooks_security.py?
test_webhooks_security.py defines 3 function(s): new_subscription, test_dummy_webhook, test_openapi_schema.
What does test_webhooks_security.py depend on?
test_webhooks_security.py imports 7 module(s): __init__.py, __init__.py, datetime, inline_snapshot, pydantic, testclient.py, typing.
Where is test_webhooks_security.py in the architecture?
test_webhooks_security.py is located at tests/test_webhooks_security.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