paper-dynasty-database/tests
Cal Corum 583bde73a9 feat(WP-07): card state API endpoints — closes #72
Add two endpoints for reading EvolutionCardState:

  GET /api/v2/teams/{team_id}/evolutions
    - Optional filters: card_type, tier
    - Pagination: page / per_page (default 10, max 100)
    - Joins EvolutionTrack so card_type filter is a single query
    - Returns {count, items} with full card state + threshold context

  GET /api/v2/evolution/cards/{card_id}
    - Resolves card_id -> (player_id, team_id) via Card table
    - Duplicate cards for same player+team share one state row
    - Returns 404 when card missing or has no evolution state

Both endpoints:
  - Require bearer token auth (valid_token dependency)
  - Embed the EvolutionTrack in each item (not just the FK id)
  - Compute next_threshold: threshold for tier above current (null at T4)
  - Share _build_card_state_response() helper in evolution.py

Also cleans up 30 pre-existing ruff violations in teams.py that were
blocking the pre-commit hook: F541 bare f-strings, E712 boolean
comparisons (now noqa where Peewee ORM requires == False/True),
and F841 unused variable assignments.

Tests: tests/test_evolution_state_api.py — 10 integration tests that
skip automatically without POSTGRES_HOST, following the same pattern as
test_evolution_track_api.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 15:33:02 -05:00
..
__init__.py feat: evolution track seed data and tests (WP-03) (#68) 2026-03-12 17:35:12 -05:00
conftest.py feat: add ProcessedGame ledger for full idempotency in update_season_stats() (#105) 2026-03-18 01:05:31 -05:00
test_evolution_evaluator.py fix: align naming between evaluator, formula engine, and DB models 2026-03-18 15:31:44 -05:00
test_evolution_init.py feat(WP-10): pack opening hook — evolution_card_state initialization 2026-03-18 13:41:05 -05:00
test_evolution_models.py feat(WP-10): pack opening hook — evolution_card_state initialization 2026-03-18 13:41:05 -05:00
test_evolution_seed.py test: add Phase 1a test suite (25 tests) 2026-03-17 19:33:49 -05:00
test_evolution_state_api.py feat(WP-07): card state API endpoints — closes #72 2026-03-18 15:33:02 -05:00
test_evolution_track_api.py feat: Track Catalog API endpoints (WP-06) (#71) 2026-03-12 20:40:38 -05:00
test_formula_engine.py fix: align tier_from_value with DB model field names (t1_threshold) 2026-03-18 15:07:07 -05:00
test_season_stats_model.py refactor: deduplicate pitcher formula and test constants 2026-03-17 09:49:33 -05:00
test_season_stats_update.py feat: add ProcessedGame ledger for full idempotency in update_season_stats() (#105) 2026-03-18 01:05:31 -05:00