- Sort Score
- Result 10 results
- Languages All
Results 221 - 230 of 1,379 for def2 (0.04 sec)
-
tests/test_reponse_set_reponse_code_empty.py
app = FastAPI() @app.delete( "/{id}", status_code=204, response_model=None, ) async def delete_deployment( id: int, response: Response, ) -> Any: response.status_code = 400 return {"msg": "Status overwritten", "id": id} client = TestClient(app) def test_dependency_set_status_code(): response = client.delete("/1")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 3.1K bytes - Viewed (0) -
tests/test_tutorial/test_response_model/test_tutorial003_02.py
from docs_src.response_model.tutorial003_02 import app client = TestClient(app) def test_get_portal(): response = client.get("/portal") assert response.status_code == 200, response.text assert response.json() == {"message": "Here's your interdimensional portal."} def test_get_redirect(): response = client.get("/portal", params={"teleport": True}, follow_redirects=False)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 3.4K bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial002.py
from fastapi.exceptions import RequestValidationError from fastapi.routing import APIRoute class ValidationErrorLoggingRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: try: return await original_route_handler(request)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 932 bytes - Viewed (0) -
docs_src/generate_clients/tutorial002.py
async def create_item(item: Item): return {"message": "Item received"} @app.get("/items/", response_model=List[Item], tags=["items"]) async def get_items(): return [ {"name": "Plumbus", "price": 3}, {"name": "Portal Gun", "price": 9001}, ] @app.post("/users/", response_model=ResponseMessage, tags=["users"]) async def create_user(user: User):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Mar 04 22:02:18 UTC 2022 - 755 bytes - Viewed (0) -
tests/test_tutorial/test_request_form_models/test_tutorial002.py
import pytest from fastapi.testclient import TestClient from tests.utils import needs_pydanticv2 @pytest.fixture(name="client") def get_client(): from docs_src.request_form_models.tutorial002 import app client = TestClient(app) return client @needs_pydanticv2 def test_post_body_form(client: TestClient): response = client.post("/login/", data={"username": "Foo", "password": "secret"})
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Sep 06 17:31:18 UTC 2024 - 6.2K bytes - Viewed (0) -
tests/test_schema_extra_examples.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Oct 24 20:26:06 UTC 2023 - 37.7K bytes - Viewed (0) -
docs_src/extra_models/tutorial001_py310.py
class UserInDB(BaseModel): username: str hashed_password: str email: EmailStr full_name: str | None = None def fake_password_hasher(raw_password: str): return "supersecret" + raw_password def fake_save_user(user_in: UserIn): hashed_password = fake_password_hasher(user_in.password) user_in_db = UserInDB(**user_in.dict(), hashed_password=hashed_password)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 899 bytes - Viewed (0) -
tests/test_empty_router.py
from fastapi.exceptions import FastAPIError from fastapi.testclient import TestClient app = FastAPI() router = APIRouter() @router.get("") def get_empty(): return ["OK"] app.include_router(router, prefix="/prefix") client = TestClient(app) def test_use_empty(): with client: response = client.get("/prefix") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Jun 11 22:37:34 UTC 2023 - 805 bytes - Viewed (0) -
tests/test_filter_pydantic_sub_model/app_pv1.py
model_b: ModelB @validator("name") def lower_username(cls, name: str, values): if not name.endswith("A"): raise ValueError("name must end in A") return name async def get_model_c() -> ModelC: return ModelC(username="test-user", password="test-password") @app.get("/model/{name}", response_model=ModelA) async def get_model_a(name: str, model_c=Depends(get_model_c)):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 784 bytes - Viewed (0) -
tests/test_custom_middleware_exception.py
max_content_size (optional): the maximum content size allowed in bytes, None for no limit """ def __init__(self, app: APIRouter, max_content_size: Optional[int] = None): self.app = app self.max_content_size = max_content_size def receive_wrapper(self, receive): received = 0 async def inner(): nonlocal received message = await receive()
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Aug 25 21:44:40 UTC 2022 - 2.8K bytes - Viewed (0)