Search Options

Results per page
Sort
Preferred Languages
Advance

Results 231 - 240 of 1,127 for def2 (0.02 sec)

  1. tests/test_tutorial/test_additional_status_codes/test_tutorial001_an_py39.py

    import pytest
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py39
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.additional_status_codes.tutorial001_an_py39 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py39
    def test_update(client: TestClient):
        response = client.put("/items/foo", json={"name": "Wrestlers"})
        assert response.status_code == 200, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 737 bytes
    - Viewed (0)
  2. tests/test_forms_single_param.py

    app = FastAPI()
    
    
    @app.post("/form/")
    def post_form(username: Annotated[str, Form()]):
        return username
    
    
    client = TestClient(app)
    
    
    def test_single_form_field():
        response = client.post("/form/", data={"username": "Rick"})
        assert response.status_code == 200, response.text
        assert response.json() == "Rick"
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Sep 05 11:24:36 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  3. 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)
  4. 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)
  5. 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)
  6. tests/test_tutorial/test_header_param_models/test_tutorial002.py

            pytest.param("tutorial002_pv1_an_py310", marks=[needs_py310, needs_pydanticv1]),
        ],
    )
    def get_client(request: pytest.FixtureRequest):
        mod = importlib.import_module(f"docs_src.header_param_models.{request.param}")
    
        client = TestClient(mod.app)
        client.headers.clear()
        return client
    
    
    def test_header_param_model(client: TestClient):
        response = client.get(
            "/items/",
            headers=[
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 9.5K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_query_param_models/test_tutorial001.py

            pytest.param("tutorial001_an_py310", marks=needs_py310),
        ],
    )
    def get_client(request: pytest.FixtureRequest):
        mod = importlib.import_module(f"docs_src.query_param_models.{request.param}")
    
        client = TestClient(mod.app)
        return client
    
    
    def test_query_param_model(client: TestClient):
        response = client.get(
            "/items/",
            params={
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 9.2K bytes
    - Viewed (0)
  8. 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)
  9. 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)
  10. 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)
Back to top