Phase 1 Database Implementation (DB-001 through DB-012): Models: - User: OAuth support (Google/Discord), premium subscriptions - Collection: Card ownership with CardSource enum - Deck: JSONB cards/energy_cards, validation state - CampaignProgress: One-to-one with User, medals/NPCs as JSONB - ActiveGame: In-progress games with GameType enum - GameHistory: Completed games with EndReason enum, replay data Infrastructure: - Alembic migrations with sync psycopg2 (avoids async issues) - Docker Compose for Postgres (5433) and Redis (6380) - App config with Pydantic settings - Redis client helper Test Infrastructure: - 68 database tests (47 model + 21 relationship) - Async factory pattern for test data creation - Sync TRUNCATE cleanup (solves pytest-asyncio event loop mismatch) - Uses dev containers instead of testcontainers for reliability Key technical decisions: - passive_deletes=True for ON DELETE SET NULL relationships - NullPool for test sessions (no connection reuse) - expire_on_commit=False with manual expire() for relationship tests
118 lines
2.6 KiB
TOML
118 lines
2.6 KiB
TOML
[project]
|
|
name = "mantimon-tcg-backend"
|
|
version = "0.1.0"
|
|
description = "Mantimon TCG - Backend API and Game Engine"
|
|
readme = "README.md"
|
|
requires-python = ">=3.12"
|
|
dependencies = [
|
|
"alembic>=1.18.1",
|
|
"asyncpg>=0.31.0",
|
|
"bcrypt>=5.0.0",
|
|
"fastapi>=0.128.0",
|
|
"passlib>=1.7.4",
|
|
"psycopg2-binary>=2.9.11",
|
|
"pydantic>=2.12.5",
|
|
"pydantic-settings>=2.12.0",
|
|
"python-jose>=3.5.0",
|
|
"python-socketio>=5.16.0",
|
|
"redis>=7.1.0",
|
|
"sqlalchemy>=2.0.46",
|
|
"uvicorn>=0.40.0",
|
|
]
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"beautifulsoup4>=4.12.0",
|
|
"black>=26.1.0",
|
|
"httpx>=0.28.1",
|
|
"mypy>=1.19.1",
|
|
"pytest>=9.0.2",
|
|
"pytest-asyncio>=1.3.0",
|
|
"pytest-cov>=7.0.0",
|
|
"requests>=2.31.0",
|
|
"ruff>=0.14.14",
|
|
"testcontainers[postgres,redis]>=4.0.0",
|
|
]
|
|
|
|
# Black configuration
|
|
[tool.black]
|
|
line-length = 100
|
|
target-version = ["py312"]
|
|
include = '\.pyi?$'
|
|
exclude = '''
|
|
/(
|
|
\.git
|
|
| \.venv
|
|
| __pycache__
|
|
| migrations
|
|
)/
|
|
'''
|
|
|
|
# Ruff configuration (fast Python linter)
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py312"
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # Pyflakes
|
|
"I", # isort
|
|
"B", # flake8-bugbear
|
|
"C4", # flake8-comprehensions
|
|
"UP", # pyupgrade
|
|
"SIM", # flake8-simplify
|
|
]
|
|
ignore = [
|
|
"E501", # line too long (handled by black)
|
|
"B008", # do not perform function calls in argument defaults (FastAPI Depends)
|
|
]
|
|
|
|
[tool.ruff.lint.isort]
|
|
known-first-party = ["app"]
|
|
|
|
# Pytest configuration
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
asyncio_mode = "auto"
|
|
asyncio_default_fixture_loop_scope = "session"
|
|
addopts = "-v --tb=short"
|
|
filterwarnings = [
|
|
"ignore::DeprecationWarning",
|
|
# Suppress async connection cleanup warnings from pytest-asyncio event loop mismatch
|
|
# These are harmless since we use NullPool + TRUNCATE for test isolation
|
|
"ignore:The garbage collector is trying to clean up:sqlalchemy.exc.SAWarning",
|
|
"ignore:coroutine 'Connection._cancel' was never awaited:RuntimeWarning",
|
|
]
|
|
|
|
# MyPy configuration
|
|
[tool.mypy]
|
|
python_version = "3.12"
|
|
strict = true
|
|
warn_return_any = true
|
|
warn_unused_ignores = true
|
|
disallow_untyped_defs = true
|
|
plugins = ["pydantic.mypy"]
|
|
|
|
[[tool.mypy.overrides]]
|
|
module = [
|
|
"redis.*",
|
|
"socketio.*",
|
|
"passlib.*",
|
|
]
|
|
ignore_missing_imports = true
|
|
|
|
# Coverage configuration
|
|
[tool.coverage.run]
|
|
source = ["app"]
|
|
branch = true
|
|
omit = ["*/tests/*", "*/__pycache__/*"]
|
|
|
|
[tool.coverage.report]
|
|
exclude_lines = [
|
|
"pragma: no cover",
|
|
"if TYPE_CHECKING:",
|
|
"raise NotImplementedError",
|
|
]
|