|
|
@ -3,13 +3,14 @@ from typing import Annotated |
|
|
|
from fastapi import FastAPI, Form |
|
|
|
from starlette.testclient import TestClient |
|
|
|
|
|
|
|
|
|
|
|
app: FastAPI = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
@app.post("/testing_alias") |
|
|
|
async def check_alias(id_test: Annotated[int, Form(alias="otherId")]): |
|
|
|
return {"other_id": id_test} |
|
|
|
|
|
|
|
|
|
|
|
@app.patch("/testing") |
|
|
|
async def check_without_alias(id_test: Annotated[int, Form()]): |
|
|
|
return {"id_test": id_test} |
|
|
@ -17,11 +18,13 @@ async def check_without_alias(id_test:Annotated[int, Form()]): |
|
|
|
|
|
|
|
client = TestClient(app) |
|
|
|
|
|
|
|
|
|
|
|
def test_without_alias(): |
|
|
|
response = client.patch("/testing", data={"id_test": 1}) |
|
|
|
assert response.status_code == 200 |
|
|
|
assert response.json() == {"id_test": 1} |
|
|
|
|
|
|
|
|
|
|
|
def test_get_alias(): |
|
|
|
response = client.post("/testing_alias", data={"otherId": "1"}) |
|
|
|
assert response.status_code == 200 |
|
|
|