test_commands.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import random
  2. from django.core import management
  3. from django.test import TestCase
  4. from events.models import Event
  5. class CommandsTestCase(TestCase):
  6. def setUp(self):
  7. random.seed(32423423433)
  8. def test_make_sample_issues(self):
  9. """ Default is one random event """
  10. management.call_command("make_sample_issues")
  11. self.assertEqual(Event.objects.all().count(), 1)
  12. def test_make_bulk_events(self):
  13. management.call_command("make_bulk_events", quantity=2)
  14. self.assertEqual(Event.objects.all().count(), 2)
  15. def test_make_sample_issues_multiple(self):
  16. """ Default is one random event """
  17. management.call_command("make_sample_issues", quantity=10)
  18. self.assertEqual(Event.objects.all().count(), 10)
  19. def test_make_sample_issues_real(self):
  20. """ Default is one random event """
  21. management.call_command("make_sample_issues", only_real=True, quantity=2)
  22. self.assertEqual(Event.objects.all().count(), 2)
  23. def test_make_sample_issues_fake(self):
  24. """ Default is one random event """
  25. management.call_command("make_sample_issues", only_fake=True)
  26. self.assertEqual(Event.objects.all().count(), 1)