Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add xfail test for non-file multipart request bodies #8

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

adriangb
Copy link
Contributor

@adriangb adriangb commented Dec 30, 2021

As per Discord discussion.

Here's the Starlette equivalent for context:

from starlette import applications, requests, responses, routing, testclient


def test_request_body_multi_part_mixed_field_content_types_starlette() -> None:
    async def test_method(request: requests.Request) -> responses.Response:
        form = await request.form()
        assert await form["file"].read() == b"file data"
        assert form["tags"] == "tags=1&tags=2"
        return responses.Response(status_code=201)
    
    app = applications.Starlette(routes=[routing.Route("/", test_method, methods=["POST"])])

    with testclient.TestClient(app) as client:
        response = client.post(
            "/",
            files=[
                ("file", ("somefile.txt", b"file data")),
                ("tags", (None, b"tags=1&tags=2", "application/x-www-form-urlencoded")),
            ],
        )
        assert response.status_code == HTTP_201_CREATED

Funding

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
Fund with Polar

@Goldziher Goldziher merged commit 2f9143d into litestar-org:main Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants