Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 1,406 for cdef (0.15 sec)

  1. tests/test_tutorial/test_dependencies/test_tutorial008d_an.py

    import pytest
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.dependencies.tutorial008d_an import app
    
        client = TestClient(app)
        return client
    
    
    def test_get_no_item(client: TestClient):
        response = client.get("/items/foo")
        assert response.status_code == 404, response.text
        assert response.json() == {"detail": "Item not found, there's only a plumbus here"}
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_bigger_applications/test_main_an.py

    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.bigger_applications.app_an.main import app
    
        client = TestClient(app)
        return client
    
    
    def test_users_token_jessica(client: TestClient):
        response = client.get("/users?token=jessica")
        assert response.status_code == 200
        assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
    
    
    def test_users_with_no_token(client: TestClient):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 24.6K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_bigger_applications/test_main_an_py39.py

    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py39
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.bigger_applications.app_an_py39.main import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py39
    def test_users_token_jessica(client: TestClient):
        response = client.get("/users?token=jessica")
        assert response.status_code == 200
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 24.9K bytes
    - Viewed (0)
  4. docs_src/app_testing/app_b_an/test_main.py

    from .main import app
    
    client = TestClient(app)
    
    
    def test_read_item():
        response = client.get("/items/foo", headers={"X-Token": "coneofsilence"})
        assert response.status_code == 200
        assert response.json() == {
            "id": "foo",
            "title": "Foo",
            "description": "There goes my hero",
        }
    
    
    def test_read_item_bad_token():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_body/test_tutorial001.py

    from unittest.mock import patch
    
    import pytest
    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture
    def client():
        from docs_src.body.tutorial001 import app
    
        client = TestClient(app)
        return client
    
    
    def test_body_float(client: TestClient):
        response = client.post("/items/", json={"name": "Foo", "price": 50.5})
        assert response.status_code == 200
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 14.7K bytes
    - Viewed (4)
  6. tests/test_tutorial/test_body/test_tutorial001_py310.py

    import pytest
    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py310
    
    
    @pytest.fixture
    def client():
        from docs_src.body.tutorial001_py310 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    def test_body_float(client: TestClient):
        response = client.post("/items/", json={"name": "Foo", "price": 50.5})
        assert response.status_code == 200
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 15K bytes
    - Viewed (1)
  7. tests/test_computed_fields.py

    
    @pytest.fixture(name="client")
    def get_client():
        app = FastAPI()
    
        from pydantic import BaseModel, computed_field
    
        class Rectangle(BaseModel):
            width: int
            length: int
    
            @computed_field
            @property
            def area(self) -> int:
                return self.width * self.length
    
        @app.get("/")
        def read_root() -> Rectangle:
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Aug 04 20:47:07 GMT 2023
    - 2.2K bytes
    - Viewed (0)
  8. tests/test_security_api_key_header.py

    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: str = Security(api_key)):
        user = User(username=oauth_header)
        return user
    
    
    @app.get("/users/me")
    def read_current_user(current_user: User = Depends(get_current_user)):
        return current_user
    
    
    client = TestClient(app)
    
    
    def test_security_api_key():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  9. tests/test_security_api_key_query_description.py

    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: str = Security(api_key)):
        user = User(username=oauth_header)
        return user
    
    
    @app.get("/users/me")
    def read_current_user(current_user: User = Depends(get_current_user)):
        return current_user
    
    
    client = TestClient(app)
    
    
    def test_security_api_key():
        response = client.get("/users/me?key=secret")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2K bytes
    - Viewed (0)
  10. tests/test_dependency_overrides.py

    router = APIRouter()
    
    
    async def common_parameters(q: str, skip: int = 0, limit: int = 100):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/main-depends/")
    async def main_depends(commons: dict = Depends(common_parameters)):
        return {"in": "main-depends", "params": commons}
    
    
    @app.get("/decorator-depends/", dependencies=[Depends(common_parameters)])
    async def decorator_depends():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 15.4K bytes
    - Viewed (0)
Back to top