Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 292 for Wain (0.19 sec)

  1. docs_src/app_testing/app_b/main.py

    }
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        id: str
        title: str
        description: Union[str, None] = None
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_main(item_id: str, x_token: str = Header()):
        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item_id not in fake_db:
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2022-05-13 23:38
    - 1.1K bytes
    - Viewed (0)
  2. docs_src/app_testing/app_b_an/test_main.py

    from fastapi.testclient import TestClient
    
    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: 2023-12-03 07:19
    - Last Modified: 2023-03-18 12:29
    - 1.8K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_testing/test_main_b_an.py

    from docs_src.app_testing.app_b_an import test_main
    
    
    def test_app():
        test_main.test_create_existing_item()
        test_main.test_create_item()
        test_main.test_create_item_bad_token()
        test_main.test_read_inexistent_item()
        test_main.test_read_item()
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-03-18 12:29
    - 302 bytes
    - Viewed (0)
  4. docs_src/bigger_applications/app/main.py

    Sebastián Ramírez <******@****.***> 1606671138 +0100
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2020-11-29 17:32
    - 552 bytes
    - Viewed (0)
  5. docs_src/settings/app03_an_py39/main.py

    Sebastián Ramírez <******@****.***> 1698179166 +0400
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-10-24 20:26
    - 462 bytes
    - Viewed (0)
  6. tests/test_tutorial/test_bigger_applications/test_main_an.py

    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    from fastapi.utils import match_pydantic_error_url
    
    
    @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
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-07-07 17:12
    - 25.2K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_bigger_applications/test_main_an_py39.py

    from fastapi.utils import match_pydantic_error_url
    
    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")
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-07-07 17:12
    - 25.6K bytes
    - Viewed (0)
  8. docs/en/docs/tutorial/testing.md

    .
    ├── app
    │   ├── __init__.py
    │   ├── main.py
    │   └── test_main.py
    ```
    
    Because this file is in the same package, you can use relative imports to import the object `app` from the `main` module (`main.py`):
    
    ```Python hl_lines="3"
    {!../../../docs_src/app_testing/test_main.py!}
    ```
    
    ...and have the code for the tests just like before.
    
    ## Testing: extended example
    
    Plain Text
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-10-17 05:59
    - 6.2K bytes
    - Viewed (0)
  9. docs_src/app_testing/app_b_py310/main.py

    }
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        id: str
        title: str
        description: str | None = None
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_main(item_id: str, x_token: str = Header()):
        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item_id not in fake_db:
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2022-05-13 23:38
    - 1.1K bytes
    - Viewed (0)
  10. docs_src/app_testing/app_b_an/main.py

    }
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        id: str
        title: str
        description: Union[str, None] = None
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_main(item_id: str, x_token: Annotated[str, Header()]):
        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item_id not in fake_db:
    Python
    - Registered: 2023-12-03 07:19
    - Last Modified: 2023-03-18 12:29
    - 1.2K bytes
    - Viewed (0)
Back to top