mirror of https://github.com/tiangolo/fastapi.git
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
This commit is contained in:
parent
9382f22468
commit
9cc86f9f74
|
|
@ -1,7 +1,6 @@
|
|||
from typing import Annotated
|
||||
|
||||
import pytest
|
||||
|
||||
from fastapi import FastAPI, Form
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
|
@ -21,26 +20,17 @@ def route_with_form_annotated(form_param: Annotated[str, Form(alias="aliased-fie
|
|||
client = TestClient(app)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path",
|
||||
["/old-style", "/annotated"]
|
||||
)
|
||||
@pytest.mark.parametrize("path", ["/old-style", "/annotated"])
|
||||
def test_get_route(path: str):
|
||||
response = client.post(path, data={"aliased-field": "Hello, World!"})
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"schema_obj",
|
||||
["Body_annotated", "Body_old_style"]
|
||||
)
|
||||
@pytest.mark.parametrize("schema_obj", ["Body_annotated", "Body_old_style"])
|
||||
def test_form_alias_is_correct(schema_obj: str):
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200, response.text
|
||||
print(response.json()["components"]["schemas"])
|
||||
form_properties = (
|
||||
response.json()
|
||||
["components"]["schemas"][schema_obj]["properties"]
|
||||
)
|
||||
form_properties = response.json()["components"]["schemas"][schema_obj]["properties"]
|
||||
assert "aliased-field" in form_properties
|
||||
|
|
|
|||
Loading…
Reference in New Issue