def test_json_body(): request = HttpRequest.from_wsgi(test_wsgi_body) body = request.parsed_body assert isinstance(body, JsonBody) assert "test_1" in body assert body["test_1"] == "1" assert body.get("test2", "default") == "default"
def test_multipart_body(): request = HttpRequest.from_wsgi(test_wsgi_body) body = request.parsed_body assert isinstance(body, MultipartBody) assert str(body["id"]) == "51b8a72aaaf909e303000034" assert str(body["test_1"]) == "only string value" assert str(body["test_2"]) == "1232" assert isinstance(body["file_a"], UploadedFile) assert isinstance(body["file_b"], UploadedFile) assert body["file_a"].filename == "orange.gif" assert body["file_b"].filename == "yellow.gif" assert body.get("test2", "default") == "default" assert len(body["file_a"]) == 49
def test_post_body(): request = HttpRequest.from_wsgi(test_wsgi_body) body = request.parsed_body assert isinstance(body, FormBody) assert str(body["test_1"]) == "1" assert body.get("test2", "default") == "default"