mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-12 13:36:41 +00:00
increase test coverage
This commit is contained in:
parent
65568065e0
commit
25fb4239cc
1 changed files with 14 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import pytest
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.openapi.models import AdditionalResponse
|
from fastapi.openapi.models import AdditionalResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
@ -409,6 +410,19 @@ openapi_schema = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_uncompatible_response_model_undecorated():
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
class NotBaseModel:
|
||||||
|
pass
|
||||||
|
|
||||||
|
response_403 = AdditionalResponse(
|
||||||
|
status_code=403, description="Forbidden", models=[NotBaseModel]
|
||||||
|
)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
app.add_api_route("/", get_not_decorated, additional_responses=[response_403])
|
||||||
|
|
||||||
|
|
||||||
def test_openapi_schema():
|
def test_openapi_schema():
|
||||||
response = client.get("/openapi.json")
|
response = client.get("/openapi.json")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue