Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 23 for userIDs (0.06 sec)

  1. tests/test_infer_param_optionality.py

    
    app.include_router(user_router, prefix="/users")
    app.include_router(item_router, prefix="/items")
    
    app.include_router(item_router, prefix="/users/{user_id}/items")
    
    
    client = TestClient(app)
    
    
    def test_get_users():
        """Check that /users returns expected data"""
        response = client.get("/users")
        assert response.status_code == 200, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 12.1K bytes
    - Viewed (0)
  2. tests/test_security_oauth2_optional_description.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    reusable_oauth2 = OAuth2(
        flows={
            "password": {
                "tokenUrl": "token",
                "scopes": {"read:users": "Read the users", "write:users": "Create users"},
            }
        },
        description="OAuth2 security scheme",
        auto_error=False,
    )
    
    
    class User(BaseModel):
        username: str
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.1K bytes
    - Viewed (0)
  3. tests/test_security_oauth2.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    reusable_oauth2 = OAuth2(
        flows={
            "password": {
                "tokenUrl": "token",
                "scopes": {"read:users": "Read the users", "write:users": "Create users"},
            }
        }
    )
    
    
    class User(BaseModel):
        username: str
    
    
    # Here we use string annotations to test them
    def get_current_user(oauth_header: "str" = Security(reusable_oauth2)):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_security/test_tutorial004.py

        response = client.get("/users/me")
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
        assert response.headers["WWW-Authenticate"] == "Bearer"
    
    
    def test_token(mod: ModuleType):
        client = TestClient(mod.app)
        access_token = get_access_token(client=client)
        response = client.get(
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 13.3K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_security/test_tutorial007.py

    
    def test_security_http_basic(client: TestClient):
        response = client.get("/users/me", auth=("stanleyjobson", "swordfish"))
        assert response.status_code == 200, response.text
        assert response.json() == {"username": "stanleyjobson"}
    
    
    def test_security_http_basic_no_credentials(client: TestClient):
        response = client.get("/users/me")
        assert response.json() == {"detail": "Not authenticated"}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  6. tests/test_security_oauth2_optional.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    reusable_oauth2 = OAuth2(
        flows={
            "password": {
                "tokenUrl": "token",
                "scopes": {"read:users": "Read the users", "write:users": "Create users"},
            }
        },
        auto_error=False,
    )
    
    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: Optional[str] = Security(reusable_oauth2)):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 8.9K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_security/test_tutorial002.py

        return client
    
    
    def test_no_token(client: TestClient):
        response = client.get("/users/me")
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
        assert response.headers["WWW-Authenticate"] == "Bearer"
    
    
    def test_token(client: TestClient):
        response = client.get("/users/me", headers={"Authorization": "Bearer testtoken"})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 2.2K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_security/test_tutorial005.py

        response = client.get("/users/me")
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
        assert response.headers["WWW-Authenticate"] == "Bearer"
    
    
    def test_token(mod: ModuleType):
        client = TestClient(mod.app)
        access_token = get_access_token(scope="me", client=client)
        response = client.get(
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 15.8K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_bigger_applications/test_main.py

        assert response.json() == {
            "openapi": "3.1.0",
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "paths": {
                "/users/": {
                    "get": {
                        "tags": ["users"],
                        "summary": "Read Users",
                        "operationId": "read_users_users__get",
                        "parameters": [
                            {
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 21.3K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_query_params/test_tutorial004.py

    @pytest.mark.parametrize(
        ("path", "expected_json"),
        [
            (
                "/users/123/items/foo",
                {
                    "item_id": "foo",
                    "owner_id": 123,
                    "description": "This is an amazing item that has a long description",
                },
            ),
            (
                "/users/1/items/bar?q=somequery",
                {
                    "item_id": "bar",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 5.3K bytes
    - Viewed (0)
Back to top