tests.py 924 B

12345678910111213141516171819202122232425262728293031
  1. from django.test import TransactionTestCase
  2. from django.core import management
  3. from .models import Book
  4. class TestNoInitialDataLoading(TransactionTestCase):
  5. """
  6. Apps with migrations should ignore initial data. This test can be removed
  7. in Django 1.9 when migrations become required and initial data is no longer
  8. supported.
  9. """
  10. available_apps = ['fixtures_migration']
  11. def test_migrate(self):
  12. self.assertQuerysetEqual(Book.objects.all(), [])
  13. management.call_command(
  14. 'migrate',
  15. verbosity=0,
  16. )
  17. self.assertQuerysetEqual(Book.objects.all(), [])
  18. def test_flush(self):
  19. self.assertQuerysetEqual(Book.objects.all(), [])
  20. management.call_command(
  21. 'flush',
  22. verbosity=0,
  23. interactive=False,
  24. load_initial_data=False
  25. )
  26. self.assertQuerysetEqual(Book.objects.all(), [])