20 lines
526 B
Python
20 lines
526 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture
|
|
def client(tmp_path: Path):
|
|
os.environ["DODO_DATABASE_URL"] = f"sqlite+aiosqlite:///{tmp_path / 'test.db'}"
|
|
os.environ["DODO_AUTO_CREATE_SCHEMA"] = "true"
|
|
from backend.config import get_settings
|
|
get_settings.cache_clear()
|
|
from backend.db import reset_engine
|
|
reset_engine()
|
|
from backend.main import app
|
|
with TestClient(app) as test_client:
|
|
yield test_client
|
|
reset_engine()
|