-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(api): local import
get_openapi
to avoid breaking all tests if …
…FastAPI changes its API
- Loading branch information
1 parent
a9a2b9f
commit fcf6a87
Showing
1 changed file
with
7 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from fastapi.openapi.utils import get_flat_models_from_routes | ||
from fastapi.utils import get_model_definitions | ||
from pydantic.schema import get_model_name_map | ||
from starlette.testclient import TestClient | ||
from antarest import __version__ | ||
|
||
|
||
def test_apidoc(client: TestClient) -> None: | ||
# Asserts that the apidoc can be loaded | ||
flat_models = get_flat_models_from_routes(client.app.routes) | ||
model_name_map = get_model_name_map(flat_models) | ||
get_model_definitions(flat_models=flat_models, model_name_map=model_name_map) | ||
# Local import to avoid breaking all tests if FastAPI changes its API | ||
from fastapi.openapi.utils import get_openapi | ||
|
||
routes = client.app.routes | ||
openapi = get_openapi(title="Antares Web", version=__version__, routes=routes) | ||
assert openapi |