Skip to content

Commit

Permalink
add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut committed Nov 24, 2024
1 parent 7a1c454 commit c51067e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/unit/test_kwargs/test_multipart_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,18 @@ async def form_(request: Request, data: Annotated[AddProductFormMsgspec, Body(me
headers={"Content-Type": "multipart/form-data; boundary=1f35df74046888ceaa62d8a534a076dd"},
)
assert response.status_code == HTTP_201_CREATED


def test_invalid_multipart_raises_client_error() -> None:
with create_test_client(form_handler) as client:
response = client.post(
"/form",
content=(
b"--20b303e711c4ab8c443184ac833ab00f\r\n"
b"Content-Disposition: form-data; "
b'name="value"\r\n\r\n'
b"--20b303e711c4ab8c44318833ab00f--\r\n"
),
headers={"Content-Type": "multipart/form-data; charset=utf-8; boundary=20b303e711c4ab8c443184ac833ab00f"},
)
assert response.status_code == HTTP_400_BAD_REQUEST

0 comments on commit c51067e

Please sign in to comment.