Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 1,300 for App (0.16 sec)

  1. tests/test_validate_response_recursive/app_pv1.py

        name: str
    
    
    RecursiveSubitemInSubmodel.update_forward_refs()
    
    
    @app.get("/items/recursive", response_model=RecursiveItem)
    def get_recursive():
        return {"name": "item", "sub_items": [{"name": "subitem", "sub_items": []}]}
    
    
    @app.get("/items/recursive-submodel", response_model=RecursiveItemViaSubmodel)
    def get_recursive_submodel():
        return {
            "name": "item",
            "sub_items1": [
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.1K bytes
    - Viewed (0)
  2. tests/test_validate_response_recursive/app_pv2.py

        name: str
    
    
    RecursiveSubitemInSubmodel.model_rebuild()
    RecursiveItemViaSubmodel.model_rebuild()
    
    
    @app.get("/items/recursive", response_model=RecursiveItem)
    def get_recursive():
        return {"name": "item", "sub_items": [{"name": "subitem", "sub_items": []}]}
    
    
    @app.get("/items/recursive-submodel", response_model=RecursiveItemViaSubmodel)
    def get_recursive_submodel():
        return {
            "name": "item",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  3. tests/test_filter_pydantic_sub_model/app_pv1.py

    from typing import Optional
    
    from fastapi import Depends, FastAPI
    from pydantic import BaseModel, validator
    
    app = FastAPI()
    
    
    class ModelB(BaseModel):
        username: str
    
    
    class ModelC(ModelB):
        password: str
    
    
    class ModelA(BaseModel):
        name: str
        description: Optional[str] = None
        model_b: ModelB
    
        @validator("name")
        def lower_username(cls, name: str, values):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 784 bytes
    - Viewed (0)
  4. docs_src/sql_databases/sql_app/tests/test_sql_app.py

    Base.metadata.create_all(bind=engine)
    
    
    def override_get_db():
        try:
            db = TestingSessionLocal()
            yield db
        finally:
            db.close()
    
    
    app.dependency_overrides[get_db] = override_get_db
    
    client = TestClient(app)
    
    
    def test_create_user():
        response = client.post(
            "/users/",
            json={"email": "******@****.***", "password": "chimichangas4life"},
        )
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jun 22 11:20:12 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  5. docs_src/sql_databases/sql_app_py310/tests/test_sql_app.py

    
    def override_get_db():
        try:
            db = TestingSessionLocal()
            yield db
        finally:
            db.close()
    
    
    app.dependency_overrides[get_db] = override_get_db
    
    client = TestClient(app)
    
    
    def test_create_user():
        response = client.post(
            "/users/",
            json={"email": "******@****.***", "password": "chimichangas4life"},
        )
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.2K bytes
    - Viewed (0)
  6. docs_src/sql_databases/sql_app_py39/tests/test_sql_app.py

    
    def override_get_db():
        try:
            db = TestingSessionLocal()
            yield db
        finally:
            db.close()
    
    
    app.dependency_overrides[get_db] = override_get_db
    
    client = TestClient(app)
    
    
    def test_create_user():
        response = client.post(
            "/users/",
            json={"email": "******@****.***", "password": "chimichangas4life"},
        )
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.2K bytes
    - Viewed (0)
  7. tests/main.py

    from fastapi import FastAPI, Path, Query
    
    app = FastAPI()
    
    
    @app.api_route("/api_route")
    def non_operation():
        return {"message": "Hello World"}
    
    
    def non_decorated_route():
        return {"message": "Hello World"}
    
    
    app.add_api_route("/non_decorated_route", non_decorated_route)
    
    
    @app.get("/text")
    def get_text():
        return "Hello World"
    
    
    @app.get("/path/{item_id}")
    def get_id(item_id):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 4.3K bytes
    - Viewed (0)
  8. tests/test_multipart_installation.py

            app = FastAPI()
    
            @app.post("/")
            async def root(f: bytes = File()):
                return f  # pragma: nocover
    
    
    def test_incorrect_multipart_installed_multi_form(monkeypatch):
        monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
        with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
            app = FastAPI()
    
            @app.post("/")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 3.7K bytes
    - Viewed (0)
  9. docs/zh/docs/advanced/testing-database.md

    但其余的会话代码基本上都是一样的,只要复制就可以了。
    
    ```Python hl_lines="8-13"
    {!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
    ```
    
    !!! tip "提示"
    
        为减少代码重复,最好把这段代码写成函数,在 `database.py` 与 `tests/test_sql_app.py`中使用。
    
        为了把注意力集中在测试代码上,本例只是复制了这段代码。
    
    ## 创建数据库
    
    因为现在是想在新文件中使用新数据库,所以要使用以下代码创建数据库:
    
    ```Python
    Base.metadata.create_all(bind=engine)
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jan 28 18:09:26 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  10. tests/test_response_model_invalid.py

    def test_invalid_response_model_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=NonPydanticModel)
            def read_root():
                pass  # pragma: nocover
    
    
    def test_invalid_response_model_sub_type_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=List[NonPydanticModel])
            def read_root():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 29 13:04:35 GMT 2020
    - 1.1K bytes
    - Viewed (0)
Back to top