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:
collerek
2023-06-18 18:52:06 +02:00
committed by GitHub
parent e72e40dd6c
commit b1ab0de4d4
27 changed files with 733 additions and 587 deletions

View File

@ -3,10 +3,11 @@ from typing import List, Optional
import databases
import pytest
import sqlalchemy
from asgi_lifespan import LifespanManager
from fastapi import FastAPI
from pydantic.schema import ForwardRef
from starlette import status
from starlette.testclient import TestClient
from httpx import AsyncClient
import ormar
@ -90,9 +91,10 @@ async def create_country(country: Country): # if this is ormar
return result
def test_payload():
client = TestClient(app)
with client as client:
@pytest.mark.asyncio
async def test_payload():
client = AsyncClient(app=app, base_url="http://testserver")
async with client as client, LifespanManager(app):
payload = {
"name": "Thailand",
"iso2": "TH",
@ -101,7 +103,9 @@ def test_payload():
"demonym": "Thai",
"native_name": "Thailand",
}
resp = client.post("/", json=payload, headers={"application-type": "json"})
resp = await client.post(
"/", json=payload, headers={"application-type": "json"}
)
# print(resp.content)
assert resp.status_code == 201