31 lines
727 B
Python
31 lines
727 B
Python
import os
|
|
import sys
|
|
|
|
# NOTE: Not sure if that was really necessary or whether this
|
|
# is just my quirky venv setup
|
|
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
PROJECT_ROOT = os.path.abspath(os.path.join(CURRENT_DIR, ".."))
|
|
|
|
if PROJECT_ROOT not in sys.path:
|
|
sys.path.insert(0, PROJECT_ROOT)
|
|
|
|
import pytest as pytest
|
|
from starlette.testclient import TestClient
|
|
|
|
import app.database as database
|
|
from app.api import app
|
|
|
|
|
|
@pytest.fixture
|
|
def client() -> TestClient:
|
|
os.environ["DB_CONNECTION"] = ":memory:"
|
|
return TestClient(app)
|
|
|
|
|
|
@pytest.fixture
|
|
def db_connection():
|
|
connection = database.connect(":memory:")
|
|
database.apply_database_schema(connection)
|
|
yield connection
|
|
connection.close()
|