Browse Source

add broker test

pull/10647/head
Nikita Pastukhov 2 years ago
parent
commit
b871b5f0a1
  1. 25
      tests/test_get_request_body.py

25
tests/test_get_request_body.py

@ -1,3 +1,5 @@
from __future__ import annotations
from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
@ -105,3 +107,26 @@ def test_openapi_schema():
}
},
}
def test_get_with_local_declared_body():
def init_app() -> FastAPI:
app = FastAPI()
class LocalProduct(BaseModel):
name: str
description: str = None # type: ignore
price: float
@app.get("/product")
async def create_item(product: LocalProduct):
return product
return app
client = TestClient(init_app())
body = {"name": "Foo", "description": "Some description", "price": 5.5}
response = client.request("GET", "/product", json=body)
assert response.json() == body

Loading…
Cancel
Save