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

@ -1,14 +1,15 @@
import json
from datetime import datetime
import uuid
from datetime import datetime
from typing import List
import databases
import pytest
import sqlalchemy
from asgi_lifespan import LifespanManager
from fastapi import Depends, FastAPI
from httpx import AsyncClient
from pydantic import BaseModel, Json
from starlette.testclient import TestClient
import ormar
from tests.settings import DATABASE_URL
@ -121,9 +122,10 @@ async def create_quiz_lol(
return await quiz.save()
def test_quiz_creation():
client = TestClient(app=router)
with client as client:
@pytest.mark.asyncio
async def test_quiz_creation():
client = AsyncClient(app=router, base_url="http://testserver")
async with client as client, LifespanManager(router):
payload = {
"title": "Some test question",
"description": "A description",
@ -145,5 +147,5 @@ def test_quiz_creation():
},
],
}
response = client.post("/create", data=json.dumps(payload))
response = await client.post("/create", json=payload)
assert response.status_code == 200