Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 543 for Code (0.19 sec)

  1. tests/test_response_code_no_body.py

    client = TestClient(app)
    
    
    def test_get_response():
        response = client.get("/a")
        assert response.status_code == 204, response.text
        assert "content-length" not in response.headers
        assert response.content == b""
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == {
            "openapi": "3.1.0",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  2. tests/test_security_oauth2_authorization_code_bearer.py

    
    def test_no_token():
        response = client.get("/items")
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
    
    
    def test_incorrect_token():
        response = client.get("/items", headers={"Authorization": "Non-existent testtoken"})
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.3K bytes
    - Viewed (0)
  3. tests/test_response_change_status_code.py

        response.status_code = 201
    
    
    async def parent_dep(result=Depends(response_status_setter)):
        return result
    
    
    @app.get("/", dependencies=[Depends(parent_dep)])
    async def get_main():
        return {"msg": "Hello World"}
    
    
    client = TestClient(app)
    
    
    def test_dependency_set_status_code():
        response = client.get("/")
        assert response.status_code == 201, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Apr 08 04:37:38 GMT 2020
    - 589 bytes
    - Viewed (0)
  4. tests/test_reponse_set_reponse_code_empty.py

    
    @app.delete(
        "/{id}",
        status_code=204,
        response_model=None,
    )
    async def delete_deployment(
        id: int,
        response: Response,
    ) -> Any:
        response.status_code = 400
        return {"msg": "Status overwritten", "id": id}
    
    
    client = TestClient(app)
    
    
    def test_dependency_set_status_code():
        response = client.delete("/1")
        assert response.status_code == 400 and response.content
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.1K bytes
    - Viewed (0)
  5. tests/test_security_oauth2_authorization_code_bearer_description.py

        tokenUrl="token",
        description="OAuth2 Code Bearer",
        auto_error=True,
    )
    
    
    @app.get("/items/")
    async def read_items(token: Optional[str] = Security(oauth2_scheme)):
        return {"token": token}
    
    
    client = TestClient(app)
    
    
    def test_no_token():
        response = client.get("/items")
        assert response.status_code == 401, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 2.4K bytes
    - Viewed (0)
  6. tests/test_query.py

        assert response.status_code == 200
        assert response.json() == "foo bar"
    
    
    def test_query_param_query_50():
        response = client.get("/query/param?query=50")
        assert response.status_code == 200
        assert response.json() == "foo bar 50"
    
    
    def test_query_param_required():
        response = client.get("/query/param-required")
        assert response.status_code == 422
        assert response.json() == IsDict(
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 11.4K bytes
    - Viewed (0)
  7. fastapi/utils.py

        Type[BaseModel], Type[BaseModel]
    ] = WeakKeyDictionary()
    
    
    def is_body_allowed_for_status_code(status_code: Union[int, str, None]) -> bool:
        if status_code is None:
            return True
        # Ref: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#patterned-fields-1
        if status_code in {
            "default",
            "1XX",
            "2XX",
            "3XX",
            "4XX",
            "5XX",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_body/test_tutorial001.py

        assert response.status_code == 200
        assert response.json() == {
            "name": "Foo",
            "price": 50.5,
            "description": None,
            "tax": None,
        }
    
    
    def test_post_with_str_float(client: TestClient):
        response = client.post("/items/", json={"name": "Foo", "price": "50.5"})
        assert response.status_code == 200
        assert response.json() == {
            "name": "Foo",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 14.7K bytes
    - Viewed (4)
  9. tests/test_tutorial/test_body/test_tutorial001_py310.py

        assert response.status_code == 200
        assert response.json() == {
            "name": "Foo",
            "price": 50.5,
            "description": None,
            "tax": None,
        }
    
    
    @needs_py310
    def test_post_with_str_float(client: TestClient):
        response = client.post("/items/", json={"name": "Foo", "price": "50.5"})
        assert response.status_code == 200
        assert response.json() == {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 15K bytes
    - Viewed (1)
  10. tests/test_tutorial/test_bigger_applications/test_main_an.py

    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):
        response = client.get("/users")
        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
    - 24.6K bytes
    - Viewed (0)
Back to top