34 lines
953 B
Python
Raw Normal View History

2025-11-08 18:20:25 +01:00
import pytest
from pathlib import Path
import json
from retoors.main import create_app
from retoors.services.user_service import UserService
from retoors.services.config_service import ConfigService
@pytest.fixture
def client(event_loop, aiohttp_client):
app = create_app()
# Create temporary data files for testing
base_path = Path(__file__).parent.parent
data_path = base_path / "data"
data_path.mkdir(exist_ok=True)
users_file = data_path / "users.json"
with open(users_file, "w") as f:
json.dump([], f)
config_file = data_path / "config.json"
with open(config_file, "w") as f:
json.dump({"price_per_gb": 0.0}, f)
app["user_service"] = UserService(users_file)
app["config_service"] = ConfigService(config_file)
yield event_loop.run_until_complete(aiohttp_client(app))
# Clean up temporary files
users_file.unlink(missing_ok=True)
config_file.unlink(missing_ok=True)