Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihweiLHBird committed Jun 9, 2024
1 parent e120e9a commit aea0431
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/extra/test_validation_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def test_validate_form(app):
class Pet:
name: str
alter_ego: List[str]
description: Optional[str] = None

@app.post("/function")
@validate(form=Pet)
Expand All @@ -348,6 +349,7 @@ async def handler(_, body: Pet):
{
"is_pet": isinstance(body, Pet),
"pet": {"name": body.name, "alter_ego": body.alter_ego},
"description": body.description if body.description else "",
}
)

Expand All @@ -359,18 +361,21 @@ async def post(self, _, body: Pet):
{
"is_pet": isinstance(body, Pet),
"pet": {"name": body.name, "alter_ego": body.alter_ego},
"description": body.description if body.description else "",
}
)

_, response = app.test_client.post("/function", data=SNOOPY_DATA)
assert response.status == 200
assert response.json["is_pet"]
assert response.json["pet"] == SNOOPY_DATA
assert response.json["description"] == ""

_, response = app.test_client.post("/method", data=SNOOPY_DATA)
assert response.status == 200
assert response.json["is_pet"]
assert response.json["pet"] == SNOOPY_DATA
assert response.json["description"] == ""


def test_validate_query(app):
Expand Down

0 comments on commit aea0431

Please sign in to comment.