generated from bisco/codex-bootstrap
feat: improve admin and add demo data command
This commit is contained in:
31
backend/shows/test_management.py
Normal file
31
backend/shows/test_management.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
|
||||
from shows.models import Performance, Show, Venue
|
||||
|
||||
|
||||
class SeedDemoDataCommandTests(TestCase):
|
||||
def test_seed_demo_data_runs_successfully(self):
|
||||
call_command("seed_demo_data")
|
||||
|
||||
self.assertEqual(Show.objects.count(), 2)
|
||||
self.assertEqual(Venue.objects.count(), 2)
|
||||
self.assertEqual(Performance.objects.count(), 3)
|
||||
self.assertTrue(Show.objects.filter(is_published=True).exists())
|
||||
|
||||
def test_seed_demo_data_is_idempotent(self):
|
||||
call_command("seed_demo_data")
|
||||
first_counts = (
|
||||
Show.objects.count(),
|
||||
Venue.objects.count(),
|
||||
Performance.objects.count(),
|
||||
)
|
||||
|
||||
call_command("seed_demo_data")
|
||||
second_counts = (
|
||||
Show.objects.count(),
|
||||
Venue.objects.count(),
|
||||
Performance.objects.count(),
|
||||
)
|
||||
|
||||
self.assertEqual(first_counts, second_counts)
|
||||
Reference in New Issue
Block a user