44 lines
848 B
Python
44 lines
848 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from app import create_app
|
|
from config import Config
|
|
|
|
|
|
@pytest.fixture()
|
|
def test_db_path(tmp_path: Path) -> str:
|
|
return str(tmp_path / "test_echo_tavern.db")
|
|
|
|
|
|
@pytest.fixture()
|
|
def app_instance(test_db_path: str):
|
|
class TestConfig(Config):
|
|
TESTING = True
|
|
DB_PATH = test_db_path
|
|
DEEPSEEK_API_KEY = ""
|
|
MAX_ROOM_PLAYERS = 8
|
|
|
|
app, socketio = create_app(TestConfig)
|
|
return app, socketio
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(app_instance):
|
|
app, _ = app_instance
|
|
return app.test_client()
|
|
|
|
|
|
@pytest.fixture()
|
|
def room_manager(app_instance):
|
|
app, _ = app_instance
|
|
return app.extensions["room_manager"]
|
|
|
|
|
|
@pytest.fixture()
|
|
def persistence(app_instance):
|
|
app, _ = app_instance
|
|
return app.extensions["persistence"]
|