Bump supported fastapi versions (#1110)
* Bump supported fastapi version to <=0.97, change all fastapi tests from starlette client to httpx.AsyncClient * Add lifecycle manager to fastapi tests * Fix coverage * Add python 3.11 to test suite, bump version
This commit is contained in:
@ -7,8 +7,9 @@ import databases
|
||||
import pydantic
|
||||
import pytest
|
||||
import sqlalchemy
|
||||
from asgi_lifespan import LifespanManager
|
||||
from fastapi import FastAPI
|
||||
from starlette.testclient import TestClient
|
||||
from httpx import AsyncClient
|
||||
|
||||
import ormar
|
||||
from tests.settings import DATABASE_URL
|
||||
@ -93,16 +94,17 @@ async def create_item(item: Organisation):
|
||||
return item
|
||||
|
||||
|
||||
def test_all_endpoints():
|
||||
client = TestClient(app)
|
||||
with client as client:
|
||||
response = client.post(
|
||||
@pytest.mark.asyncio
|
||||
async def test_all_endpoints():
|
||||
client = AsyncClient(app=app, base_url="http://testserver")
|
||||
async with client as client, LifespanManager(app):
|
||||
response = await client.post(
|
||||
"/items/",
|
||||
json={"id": 1, "ident": "", "priority": 4, "expire_date": "2022-05-01"},
|
||||
)
|
||||
|
||||
assert response.status_code == 422
|
||||
response = client.post(
|
||||
response = await client.post(
|
||||
"/items/",
|
||||
json={
|
||||
"id": 1,
|
||||
@ -124,7 +126,7 @@ def test_all_endpoints():
|
||||
assert response.status_code == 200
|
||||
item = Organisation(**response.json())
|
||||
assert item.pk is not None
|
||||
response = client.get("/docs/")
|
||||
response = await client.get("/docs")
|
||||
assert response.status_code == 200
|
||||
assert b"<title>FastAPI - Swagger UI</title>" in response.content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user