- Initialize project with uv, FastAPI, and libsql-client for Turso persistence - Implement local SQLite fallback (`file:local.db`) for zero-friction development and testing - Create schema and seeder with 9 therapy services from Armonía del Ser flyer - Implement POST /bookings with automatic WhatsApp deep-link generation and SPEI instructions - Implement POST /payments/verify 1-tap admin acknowledgment flow - Add automated test suite with 5 passing tests and verification gates (ruff, pyright, pytest)
40 lines
762 B
Python
40 lines
762 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
# Ensure test DB is used
|
|
TEST_DB = "test_armonia.db"
|
|
os.environ["DATABASE_URL"] = f"file:{TEST_DB}"
|
|
|
|
from app.core.config import settings
|
|
|
|
settings.database_url = f"file:{TEST_DB}"
|
|
|
|
import asyncio
|
|
|
|
from app.db.init_db import init_schema_and_seed
|
|
from app.main import app
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def setup_test_db():
|
|
# Remove existing test DB if any
|
|
if Path(TEST_DB).exists():
|
|
Path(TEST_DB).unlink()
|
|
|
|
asyncio.run(init_schema_and_seed())
|
|
yield
|
|
|
|
if Path(TEST_DB).exists():
|
|
Path(TEST_DB).unlink()
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
with TestClient(app) as c:
|
|
yield c
|