Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 18 for test_invalid (0.28 sec)

  1. tests/test_invalid_path_param.py

    import pytest
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    
    def test_invalid_sequence():
        with pytest.raises(AssertionError):
            app = FastAPI()
    
            class Item(BaseModel):
                title: str
    
            @app.get("/items/{id}")
            def read_items(id: List[Item]):
                pass  # pragma: no cover
    
    
    def test_invalid_tuple():
        with pytest.raises(AssertionError):
            app = FastAPI()
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Mon Jun 03 17:59:40 GMT 2019
    - 1.7K bytes
    - Viewed (0)
  2. tests/test_invalid_sequence_param.py

    from fastapi import FastAPI, Query
    from pydantic import BaseModel
    
    
    def test_invalid_sequence():
        with pytest.raises(AssertionError):
            app = FastAPI()
    
            class Item(BaseModel):
                title: str
    
            @app.get("/items/")
            def read_items(q: List[Item] = Query(default=None)):
                pass  # pragma: no cover
    
    
    def test_invalid_tuple():
        with pytest.raises(AssertionError):
            app = FastAPI()
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 1.2K bytes
    - Viewed (0)
  3. tests/test_response_model_invalid.py

    from fastapi.exceptions import FastAPIError
    
    
    class NonPydanticModel:
        pass
    
    
    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()
    
    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)
  4. tests/test_validate_response.py

            {"name": "bar", "price": "bar"},
            {"name": "baz", "price": "baz"},
        ]
    
    
    client = TestClient(app)
    
    
    def test_invalid():
        with pytest.raises(ResponseValidationError):
            client.get("/items/invalid")
    
    
    def test_invalid_none():
        with pytest.raises(ResponseValidationError):
            client.get("/items/invalidnone")
    
    
    def test_valid_none_data():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 2K bytes
    - Viewed (0)
  5. tests/test_validate_response_dataclass.py

            {"name": "baz", "price": "baz"},
        ]
    
    
    client = TestClient(app)
    
    
    def test_invalid():
        with pytest.raises(ResponseValidationError):
            client.get("/items/invalid")
    
    
    def test_double_invalid():
        with pytest.raises(ResponseValidationError):
            client.get("/items/innerinvalid")
    
    
    def test_invalid_list():
        with pytest.raises(ResponseValidationError):
    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)
  6. tests/test_route_scope.py

        assert response.status_code == 200, response.text
        assert response.json() == {"user_id": "rick", "path": "/users/{user_id}"}
    
    
    def test_invalid_method_doesnt_match():
        response = client.post("/users/rick")
        assert response.status_code == 405, response.text
    
    
    def test_invalid_path_doesnt_match():
        response = client.post("/usersx/rick")
        assert response.status_code == 404, response.text
    
    
    def test_websocket():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Feb 08 10:23:07 GMT 2023
    - 1.5K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_response_model/test_tutorial003_04.py

    import pytest
    from fastapi.exceptions import FastAPIError
    
    
    def test_invalid_response_model():
        with pytest.raises(FastAPIError):
            from docs_src.response_model.tutorial003_04 import app
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Jan 10 16:22:47 GMT 2023
    - 236 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_response_model/test_tutorial003_04_py310.py

    import pytest
    from fastapi.exceptions import FastAPIError
    
    from ...utils import needs_py310
    
    
    @needs_py310
    def test_invalid_response_model():
        with pytest.raises(FastAPIError):
            from docs_src.response_model.tutorial003_04_py310 import app
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Jan 10 16:22:47 GMT 2023
    - 289 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_body_fields/test_tutorial001_an_py310.py

            "item_id": 6,
            "item": {
                "name": "Bar",
                "price": 0.2,
                "description": "Some bar",
                "tax": 5.4,
            },
        }
    
    
    @needs_py310
    def test_invalid_price(client: TestClient):
        response = client.put("/items/5", json={"item": {"name": "Foo", "price": -3.0}})
        assert response.status_code == 422
        assert response.json() == IsDict(
            {
                "detail": [
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.3K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_body_fields/test_tutorial001.py

            "item_id": 6,
            "item": {
                "name": "Bar",
                "price": 0.2,
                "description": "Some bar",
                "tax": 5.4,
            },
        }
    
    
    def test_invalid_price(client: TestClient):
        response = client.put("/items/5", json={"item": {"name": "Foo", "price": -3.0}})
        assert response.status_code == 422
        assert response.json() == IsDict(
            {
                "detail": [
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.2K bytes
    - Viewed (0)
Back to top