Add test data injection script with varied runs and encounters

Creates 6 runs across FireRed, Platinum, Emerald, HeartGold, Black, and
Crystal with mixed statuses (failed/completed/active), diverse encounter
states (caught/fainted/missed/evolved/dead), and varied rule configs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 20:35:59 +01:00
parent c2112b9b74
commit 78d31f2856
2 changed files with 362 additions and 13 deletions

View File

@@ -1,22 +1,38 @@
---
# nuzlocke-tracker-ycfs
title: Inject test data into dev environment
status: todo
status: completed
type: task
priority: normal
created_at: 2026-02-06T09:48:38Z
updated_at: 2026-02-06T09:48:38Z
updated_at: 2026-02-07T19:35:11Z
---
Create a mechanism to populate the development database with realistic test data for manual testing and development.
Create a script to populate the development database with realistic test data for manual testing.
## Goals
- Enable developers to quickly set up a populated dev environment
- Provide realistic data scenarios for testing UI components
- Support resetting/refreshing test data easily
## Requirements
- Multiple runs across different games with varied statuses:
- 2 failed runs (different games, progressed partway)
- 2 completed runs (different games, most routes visited)
- 2 active/in-progress runs (different games, early-to-mid progress)
- Each run should have a mix of encounter states:
- Caught (alive): with nicknames, catch levels
- Caught (dead): with faint_level, death_cause
- Fainted (failed to catch)
- Missed (ran away / KOd)
- Some caught Pokemon should be evolved (current_pokemon_id set via the evolutions table)
- Runs should use varied rule configurations (some with pinwheel clause off, some with hardcore mode, etc.)
- Respects the one-encounter-per-group constraint (only one child route per parent group gets an encounter, unless pinwheel zones apply)
## Potential Checklist
- [ ] Define test data requirements (users, playthroughs, encounters, etc.)
- [ ] Create test data fixtures or factory functions
- [ ] Add CLI command or script to inject test data
- [ ] Document how to use the test data injection
- [ ] Ensure test data can be reset/cleared if needed
## Implementation
- Add inject_test_data.py to backend/src/app/seeds/
- Follows the same async session pattern as run.py
- Queries DB for real game_ids, route_ids, pokemon_ids, and evolution chains so data is always valid
- Invocable via python -m app.seeds.inject_test_data (standalone entry block)
- Clears existing runs+encounters before injecting (idempotent)
- Prints summary of what was created
## Checklist
- [x] Create inject_test_data.py with test data injection logic
- [x] Wire up as standalone script (python -m app.seeds.inject_test_data)
- [x] Verify it runs cleanly against a seeded database