feat: add scouting sample seed data baseline

This commit is contained in:
bisco
2026-04-07 16:46:59 +02:00
parent 3e6fb34017
commit ff4a3020d5
7 changed files with 396 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from datetime import date
from decimal import Decimal
from django.core.management import call_command
from django.test import TestCase
from django.urls import reverse
@ -236,3 +237,38 @@ class ScoutingSearchViewsTests(TestCase):
)
self.assertContains(response, self.player_pg.full_name)
self.assertNotContains(response, self.player_wing.full_name)
class SeedScoutingDataCommandTests(TestCase):
def test_seed_command_creates_expected_core_objects(self):
call_command("seed_scouting_data")
self.assertGreaterEqual(Competition.objects.count(), 3)
self.assertGreaterEqual(Team.objects.count(), 4)
self.assertGreaterEqual(Season.objects.count(), 3)
self.assertGreaterEqual(Player.objects.count(), 5)
self.assertGreaterEqual(PlayerSeason.objects.count(), 6)
self.assertEqual(PlayerSeason.objects.count(), PlayerSeasonStats.objects.count())
player = Player.objects.get(full_name="Marco Guard")
self.assertEqual(player.position, Player.Position.PG)
self.assertTrue(player.roles.filter(slug="playmaker").exists())
self.assertTrue(player.specialties.filter(slug="ball-handling").exists())
def test_seed_command_is_idempotent_for_repeat_runs(self):
call_command("seed_scouting_data")
first_counts = {
"players": Player.objects.count(),
"contexts": PlayerSeason.objects.count(),
"stats": PlayerSeasonStats.objects.count(),
"roles": Role.objects.count(),
"specialties": Specialty.objects.count(),
}
call_command("seed_scouting_data")
self.assertEqual(Player.objects.count(), first_counts["players"])
self.assertEqual(PlayerSeason.objects.count(), first_counts["contexts"])
self.assertEqual(PlayerSeasonStats.objects.count(), first_counts["stats"])
self.assertEqual(Role.objects.count(), first_counts["roles"])
self.assertEqual(Specialty.objects.count(), first_counts["specialties"])