Skip to content

Commit

Permalink
Merge pull request #681 from python-openapi/fix/starlette-binary-requ…
Browse files Browse the repository at this point in the history
…est-test-fix

Starlette binary request test fix
  • Loading branch information
p1c2u authored Sep 26, 2023
2 parents 1eff5a2 + 1384e55 commit 9c8f082
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ def pet_photo_endpoint(request):
if request.method == "GET":
response = StreamingResponse([OPENID_LOGO], media_type="image/gif")
elif request.method == "POST":
with request.form() as form:
filename = form["file"].filename
contents = form["file"].read()
response = Response(status_code=201)
contents = request.body()
response = Response(status_code=201)
openapi_response = StarletteOpenAPIResponse(response)
response_unmarshalled = unmarshal_response(
openapi_request, openapi_response, spec=spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ def test_post_valid(self, client, data_gif):
"Api-Key": self.api_key_encoded,
"Content-Type": content_type,
}
data = {
"file": data_gif,
}

cookies = {"user": "1"}
response = client.post(
"/v1/pets/1/photo",
headers=headers,
data=data,
data=data_gif,
cookies=cookies,
)

Expand Down

0 comments on commit 9c8f082

Please sign in to comment.