-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
30 lines (22 loc) · 793 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
import pytest
from asgi_lifespan import LifespanManager
from httpx import AsyncClient
from tortoise import Tortoise
from app.database.seeders import sample_seeders
from app.main import app
test_user = {"username": "test", "password": "test"}
@pytest.fixture(scope="session")
def anyio_backend():
return "asyncio"
@pytest.fixture(scope="session")
async def client():
async with LifespanManager(app):
await Tortoise.init(
db_url="sqlite://:memory:",
modules={"models": ["app.database.models"]},
)
await Tortoise.generate_schemas()
await sample_seeders.generate_seeders(number_of_users=1, test_user=test_user)
async with AsyncClient(app=app, base_url="http://test") as c:
yield c