generated from bisco/codex-bootstrap
32 lines
975 B
Python
32 lines
975 B
Python
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)
|