[tests] Port first test to async #23
This commit is contained in:
parent
64715f5aa5
commit
48e3b6f6bc
|
@ -66,6 +66,7 @@ commands =
|
|||
deps =
|
||||
pytest
|
||||
pytest-asyncio
|
||||
trio
|
||||
commands =
|
||||
pytest tests
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ from urllib.parse import urlparse
|
|||
|
||||
from fastapi import FastAPI, status
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import AsyncClient
|
||||
from pytest import fixture
|
||||
|
||||
from kibicara import email
|
||||
|
@ -24,6 +25,15 @@ def client():
|
|||
return TestClient(app)
|
||||
|
||||
|
||||
@fixture(scope="module")
|
||||
def asyncclient():
|
||||
Mapping.drop_all()
|
||||
Mapping.create_all()
|
||||
app = FastAPI()
|
||||
app.include_router(router, prefix="/api")
|
||||
return AsyncClient(app=app, base_url="http://test")
|
||||
|
||||
|
||||
@fixture(scope="module")
|
||||
def monkeymodule():
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
# SPDX-License-Identifier: 0BSD
|
||||
|
||||
from fastapi import status
|
||||
import pytest
|
||||
|
||||
|
||||
def test_hoods_unauthorized(client):
|
||||
response = client.get("/api/admin/hoods/")
|
||||
@pytest.mark.anyio
|
||||
async def test_hoods_unauthorized(asyncclient):
|
||||
response = await asyncclient.get("/api/admin/hoods/")
|
||||
assert response.status_code == status.HTTP_401_UNAUTHORIZED
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue