test_commands.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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_issues_real(self):
  19. """Issue quantity determines number of events for only_real"""
  20. management.call_command("make_sample_issues", only_real=True, issue_quantity=2)
  21. self.assertEqual(Event.objects.all().count(), 2)
  22. def test_make_sample_events(self):
  23. management.call_command(
  24. "make_sample_events",
  25. quantity=2,
  26. )
  27. self.assertEqual(Event.objects.all().count(), 2)