Browse Source

Move tests for async openapi func to dedicated test file

pull/10638/head
bkis 2 months ago
parent
commit
6d744bdcd1
  1. 13
      tests/test_application.py
  2. 14
      tests/test_openapi_async.py

13
tests/test_application.py

@ -1,6 +1,5 @@
import pytest
from dirty_equals import IsDict
from fastapi import FastAPI
from fastapi.testclient import TestClient
from .main import app
@ -53,18 +52,6 @@ def test_enum_status_code_response():
assert response.json() == "foo bar"
def test_allow_async_openapi():
async def async_openapi():
return {"foo": "bar"}
mod_app = FastAPI() # use fresh instance to not affect other tests
mod_app.openapi = async_openapi
mod_client = TestClient(mod_app)
response = mod_client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == {"foo": "bar"}
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

14
tests/test_openapi_async.py

@ -0,0 +1,14 @@
from fastapi import FastAPI
from fastapi.testclient import TestClient
def test_allow_async_openapi():
async def async_openapi():
return {"foo": "bar"}
mod_app = FastAPI() # use fresh instance to not affect other tests
mod_app.openapi = async_openapi
mod_client = TestClient(mod_app)
response = mod_client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == {"foo": "bar"}
Loading…
Cancel
Save