test_commands.py 885 B

123456789101112131415161718192021222324252627282930
  1. import random
  2. from django.core import management
  3. from django.test import TestCase
  4. from events.models import Event
  5. from issues.models import Issue
  6. class CommandsTestCase(TestCase):
  7. def setUp(self):
  8. random.seed(32423423433)
  9. def test_make_sample_issues(self):
  10. management.call_command("make_sample_issues", issue_quantity=1)
  11. self.assertEqual(Issue.objects.all().count(), 1)
  12. def test_make_sample_issues_multiple(self):
  13. management.call_command(
  14. "make_sample_issues", issue_quantity=2, events_quantity_per=2
  15. )
  16. self.assertEqual(Issue.objects.all().count(), 2)
  17. self.assertEqual(Event.objects.all().count(), 4)
  18. def test_make_sample_events(self):
  19. management.call_command(
  20. "make_sample_events",
  21. quantity=2,
  22. )
  23. self.assertEqual(Event.objects.all().count(), 2)