feat: evolution track seed data and tests (WP-03) (#68) #83
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#83
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database#68"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #68
Summary
Creates the three universal evolution tracks as a locked seed data fixture.
app/seed/evolution_tracks.json— locked JSON with 3 track rows (Batter, Starting Pitcher, Relief Pitcher)app/seed/evolution_tracks.py—load_tracks()+seed(model_class=None)usingget_or_create; lazy-importsEvolutionTrackfromdb_engine(WP-01 dependency)tests/test_evolution_seed.py— 5 unit tests (JSON fixture only, no DB) + 1 integration test (in-memory SQLite stub model)tests/__init__.py— package markerTest results
All tests from the issue checklist covered:
Notes
The integration test defines a minimal
EvolutionTrackStubPeewee model bound to in-memory SQLite so the test suite can run before WP-01 (EvolutionTrack model) is merged. Once WP-01 lands,seed()with no arguments will useapp.db_engine.EvolutionTrackdirectly.AI Code Review
Files Reviewed
app/seed/__init__.py(added — empty package marker)app/seed/evolution_tracks.json(added)app/seed/evolution_tracks.py(added)tests/__init__.py(added — empty package marker)tests/test_evolution_seed.py(added)Findings
Correctness
t1 < t2 < t3 < t4, all positive. Batter (37/149/448/896), SP (10/40/120/240), RP (3/12/35/70). ✓get_or_create(card_type=..., defaults=track)is correct. Thedefaultsdict includescard_type(a duplicate of the lookup key) — Peewee ignores the duplicate indefaultsduring create and uses the kwarg value, so this is harmless. Works as intended.from app.db_engine import EvolutionTrackcorrectly defers the WP-01 dependency. ConfirmedEvolutionTrackis not yet indb_engine.py, soseed()withoutmodel_classwill fail until WP-01 merges — expected and documented.created=True, second call asserts allcreated=False, final row count is 3. ✓Edge Cases
load_tracks()will raiseFileNotFoundError/json.JSONDecodeErroron fixture file issues — appropriate loud failure for a deployment error._test_db.connect(reuse_if_open=True)+drop_tablesafter each test correctly isolates tests while keeping the in-memory connection alive across the suite.Security
Style & Conventions
# noqa: PLC0415on the mid-function import is correct and appropriate.Suggestions
autouse=Trueapplies DB fixture to all 6 tests: The 5 pure JSON unit tests don't touch the database, but they still get_db's connect/create/drop cycle on every run. Not a bug, but adds minor overhead. Consider scoping the DB fixture to the integration test only (e.g., apply the fixture directly ontest_seed_is_idempotentinstead ofautouse=True). Low priority.card_typeindefaults:defaults=trackpassescard_typeboth as the lookup key and inside the defaults dict. Functionally harmless, butdefaults={k: v for k, v in track.items() if k != "card_type"}would be semantically cleaner. Low priority.Verdict: APPROVED
Clean, focused implementation. Scope exactly matches the PR description. All 6 test cases cover the issue checklist. No correctness bugs, no security issues. Dependency on WP-01 is correctly deferred with a lazy import and well-documented stub for the integration test.
Automated review by Claude PR Reviewer (posted as comment — Gitea self-review restriction)