|
@ -1,9 +1,9 @@ |
|
|
from fastapi import FastAPI, Form |
|
|
from fastapi import FastAPI, Form |
|
|
from starlette.testclient import TestClient |
|
|
from starlette.testclient import TestClient |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app: FastAPI = FastAPI() |
|
|
app: FastAPI = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/testing_alias") |
|
|
@app.post("/testing_alias") |
|
|
async def check_alias(id_test: int = Form(alias="otherId")): |
|
|
async def check_alias(id_test: int = Form(alias="otherId")): |
|
|
return {"other_id":id_test} |
|
|
return {"other_id":id_test} |
|
@ -12,7 +12,6 @@ async def check_alias(id_test: int = Form(alias="otherId")): |
|
|
async def check_without_alias(id_test:int = Form()): |
|
|
async def check_without_alias(id_test:int = Form()): |
|
|
return {"id_test":id_test} |
|
|
return {"id_test":id_test} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client = TestClient(app) |
|
|
client = TestClient(app) |
|
|
|
|
|
|
|
|
def test_without_alias(): |
|
|
def test_without_alias(): |
|
@ -20,6 +19,7 @@ def test_without_alias(): |
|
|
assert response.status_code == 200 |
|
|
assert response.status_code == 200 |
|
|
assert response.json() == {"id_test": 1} |
|
|
assert response.json() == {"id_test": 1} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_alias(): |
|
|
def test_get_alias(): |
|
|
response = client.post("/testing_alias", data={"otherId": "1"}) |
|
|
response = client.post("/testing_alias", data={"otherId": "1"}) |
|
|
assert response.status_code == 200 |
|
|
assert response.status_code == 200 |
|
|