Search Options

Results per page
Sort
Preferred Languages
Advance

Results 121 - 130 of 1,379 for def2 (0.1 sec)

  1. tests/test_regex_deprecated_params.py

    from fastapi import FastAPI, Query
    from fastapi.testclient import TestClient
    from typing_extensions import Annotated
    
    from .utils import needs_py310
    
    
    def get_client():
        app = FastAPI()
        with pytest.warns(DeprecationWarning):
    
            @app.get("/items/")
            async def read_items(
                q: Annotated[str | None, Query(regex="^fixedquery$")] = None,
            ):
                if q:
                    return f"Hello {q}"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 5.5K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_security/test_tutorial006_an.py

    from docs_src.security.tutorial006_an import app
    
    client = TestClient(app)
    
    
    def test_security_http_basic():
        response = client.get("/users/me", auth=("john", "secret"))
        assert response.status_code == 200, response.text
        assert response.json() == {"username": "john", "password": "secret"}
    
    
    def test_security_http_basic_no_credentials():
        response = client.get("/users/me")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.3K bytes
    - Viewed (0)
  3. tests/test_security_oauth2_optional.py

    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: Optional[str] = Security(reusable_oauth2)):
        if oauth_header is None:
            return None
        user = User(username=oauth_header)
        return user
    
    
    @app.post("/login")
    def login(form_data: OAuth2PasswordRequestFormStrict = Depends()):
        return form_data
    
    
    @app.get("/users/me")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 10.8K bytes
    - Viewed (0)
  4. tests/test_repeated_cookie_headers.py

    app = FastAPI()
    
    
    def set_cookie(*, response: Response):
        response.set_cookie("cookie-name", "cookie-value")
        return {}
    
    
    def set_indirect_cookie(*, dep: str = Depends(set_cookie)):
        return dep
    
    
    @app.get("/directCookie")
    def get_direct_cookie(dep: str = Depends(set_cookie)):
        return {"dep": dep}
    
    
    @app.get("/indirectCookie")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jun 13 12:44:51 UTC 2020
    - 792 bytes
    - Viewed (0)
  5. tests/test_router_redirect_slashes.py

    from fastapi import APIRouter, FastAPI
    from fastapi.testclient import TestClient
    
    
    def test_redirect_slashes_enabled():
        app = FastAPI()
        router = APIRouter()
    
        @router.get("/hello/")
        def hello_page() -> str:
            return "Hello, World!"
    
        app.include_router(router)
    
        client = TestClient(app)
    
        response = client.get("/hello/", follow_redirects=False)
        assert response.status_code == 200
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Jun 22 10:37:50 UTC 2023
    - 974 bytes
    - Viewed (0)
  6. tests/test_annotated.py

    
    @app.get("/default")
    async def default(foo: Annotated[str, Query()] = "foo"):
        return {"foo": foo}
    
    
    @app.get("/required")
    async def required(foo: Annotated[str, Query(min_length=1)]):
        return {"foo": foo}
    
    
    @app.get("/multiple")
    async def multiple(foo: Annotated[str, object(), Query(min_length=1)]):
        return {"foo": foo}
    
    
    @app.get("/unrelated")
    async def unrelated(foo: Annotated[str, object()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 10.2K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_query_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.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
    - 10.4K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_request_files/test_tutorial002_py39.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py39
    
    
    @pytest.fixture(name="app")
    def get_app():
        from docs_src.request_files.tutorial002_py39 import app
    
        return app
    
    
    @pytest.fixture(name="client")
    def get_client(app: FastAPI):
        client = TestClient(app)
        return client
    
    
    file_required = {
        "detail": [
            {
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 9K bytes
    - Viewed (0)
  9. tests/test_response_code_no_body.py

        response_class=JsonApiResponse,
        responses={500: {"description": "Error", "model": JsonApiError}},
    )
    async def a():
        pass
    
    
    @app.get("/b", responses={204: {"description": "No Content"}})
    async def b():
        pass  # pragma: no cover
    
    
    client = TestClient(app)
    
    
    def test_get_response():
        response = client.get("/a")
        assert response.status_code == 204, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.2K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_query_params_str_validations/test_tutorial012_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.query_params_str_validations.tutorial012_an_py39 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py39
    def test_default_query_values(client: TestClient):
        url = "/items/"
        response = client.get(url)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.6K bytes
    - Viewed (0)
Back to top