- Refactored TimerPage component to improve layout and user experience. - Updated theme configuration to utilize design tokens for better maintainability. - Introduced new tokens for colors and typography to align with design principles. - Simplified state management and improved timer functionality. - Enhanced accessibility and responsiveness of UI elements.
68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
"""Test fixtures.
|
|
|
|
The engine is built at import time from the environment, so the database URL has
|
|
to be set before anything from `app` is imported — hence the env juggling here
|
|
rather than in a fixture.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import tempfile
|
|
|
|
import pytest
|
|
|
|
# Before anything imports the settings: no `.env`, ever. A developer's real
|
|
# file would otherwise point the suite at live Jira, Telegram and laundry.
|
|
os.environ["KADENCE_NO_DOTENV"] = "1"
|
|
os.environ.setdefault("DATABASE_URL", "sqlite:///" + tempfile.mktemp(suffix=".db"))
|
|
os.environ["SCHEDULER_ENABLED"] = "false"
|
|
os.environ["TELEGRAM_BOT_ENABLED"] = "false"
|
|
# Keep the seeded settings empty so tests never reach a real Jira/Todoist.
|
|
for name in (
|
|
"JIRA_BASE_URL",
|
|
"JIRA_EMAIL",
|
|
"JIRA_API_TOKEN",
|
|
"TODOIST_API_TOKEN",
|
|
"GOOGLE_CLIENT_ID",
|
|
"GOOGLE_CLIENT_SECRET",
|
|
"GOOGLE_REFRESH_TOKEN",
|
|
"LAUNDRY_SESSION",
|
|
"TELEGRAM_BOT_TOKEN",
|
|
"TELEGRAM_CHAT_ID",
|
|
"SLACK_WEBHOOK_URL",
|
|
):
|
|
os.environ.pop(name, None)
|
|
|
|
from app.db import Base, SessionLocal, engine, init_db # noqa: E402
|
|
from app.services import settings_service # noqa: E402
|
|
from app.settings_schema import AppSettings # noqa: E402
|
|
|
|
|
|
@pytest.fixture()
|
|
def session():
|
|
Base.metadata.drop_all(bind=engine)
|
|
init_db()
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
|
|
@pytest.fixture()
|
|
def settings(session) -> AppSettings:
|
|
return settings_service.load_settings(session)
|
|
|
|
|
|
@pytest.fixture()
|
|
def client():
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.main import app
|
|
|
|
Base.metadata.drop_all(bind=engine)
|
|
init_db()
|
|
with TestClient(app) as test_client:
|
|
yield test_client
|