Beispiel #1
0
 async def post(
         self,
         model: UserModel = Body.i(),
         other_model: UserOtherModel = Body.i(),
 ) -> response.HTTPResponse:
     return_dict = model.dict()
     return_dict.update(other_model.dict())
     return_dict.update({"user_agent": self.user_agent})
     return response.json({"code": 0, "msg": "", "data": return_dict})
Beispiel #2
0
 def post(
         self,
         model: UserModel = Body.i(),
         other_model: UserOtherModel = Body.i(),
 ) -> dict:
     return_dict = model.dict()
     return_dict.update(other_model.dict())
     return_dict.update({"user_agent": self.user_agent})
     return {"code": 0, "msg": "", "data": return_dict}
Beispiel #3
0
async def test_depend(
    request: Request,
    model: UserModel = Query.i(),
    depend_tuple: Tuple[str, int] = Depends.i(demo_depend),
) -> response.HTTPResponse:
    """Test Method:Post request, Pydantic Model"""
    assert request is not None, "Not found request"
    return_dict = model.dict()
    return_dict.update({"user_agent": depend_tuple[0], "age": depend_tuple[1]})
    return response.json({"code": 0, "msg": "", "data": return_dict})
Beispiel #4
0
async def test_raise_tip(
    model: UserModel = Body.i(),
    other_model: UserOtherModel = Body.i(),
    content_type: str = Header.i(description="content-type"),
) -> response.HTTPResponse:
    """Test Method: error tip"""
    return_dict = model.dict()
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content_type})
    return response.json({"code": 0, "msg": "", "data": return_dict})
Beispiel #5
0
async def test_post(
    model: UserModel = Body.i(),
    other_model: UserOtherModel = Body.i(),
    sex: SexEnum = Body.i(description="sex"),
    content_type: str = Header.i(alias="Content-Type", description="content-type"),
) -> JSONResponse:
    """Test Method:Post Pydantic Model"""
    return_dict = model.dict()
    return_dict["sex"] = sex.value
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content_type})
    return JSONResponse({"code": 0, "msg": "", "data": return_dict})
Beispiel #6
0
def test_raise_tip(
        model: UserModel = Body.i(),
        other_model: UserOtherModel = Body.i(),
        content__type: str = Header.i(
            description="Content-Type"
        ),  # in flask, Content-Type's key is content_type
) -> dict:
    """Test Method: error tip"""
    return_dict = model.dict()
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content__type})
    return {"code": 0, "msg": "", "data": return_dict}