From 25fb4239cc2751b9608e7e92e3b9b42be31a9337 Mon Sep 17 00:00:00 2001 From: Mohammed Date: Sat, 23 Mar 2019 01:13:09 +0300 Subject: [PATCH] increase test coverage --- tests/test_additional_responses.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_additional_responses.py b/tests/test_additional_responses.py index ddd5b7664..aa18dfbc6 100644 --- a/tests/test_additional_responses.py +++ b/tests/test_additional_responses.py @@ -1,3 +1,4 @@ +import pytest from fastapi import FastAPI from fastapi.openapi.models import AdditionalResponse 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(): response = client.get("/openapi.json") assert response.status_code == 200