2014-10-25 03:29:59 +08:00
|
|
|
from django.core import management
|
2015-02-10 02:19:34 +08:00
|
|
|
from django.test import TransactionTestCase
|
2014-10-25 03:29:59 +08:00
|
|
|
|
|
|
|
from .models import Book
|
|
|
|
|
|
|
|
|
2014-10-19 05:01:13 +08:00
|
|
|
class TestNoInitialDataLoading(TransactionTestCase):
|
2014-10-25 03:29:59 +08:00
|
|
|
"""
|
|
|
|
Apps with migrations should ignore initial data. This test can be removed
|
|
|
|
in Django 1.9 when migrations become required and initial data is no longer
|
|
|
|
supported.
|
|
|
|
"""
|
|
|
|
available_apps = ['fixtures_migration']
|
|
|
|
|
|
|
|
def test_migrate(self):
|
|
|
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
|
|
|
management.call_command(
|
|
|
|
'migrate',
|
|
|
|
verbosity=0,
|
|
|
|
)
|
|
|
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
|
|
|
|
|
|
|
def test_flush(self):
|
|
|
|
self.assertQuerysetEqual(Book.objects.all(), [])
|
|
|
|
management.call_command(
|
|
|
|
'flush',
|
|
|
|
verbosity=0,
|
|
|
|
interactive=False,
|
|
|
|
load_initial_data=False
|
|
|
|
)
|
|
|
|
self.assertQuerysetEqual(Book.objects.all(), [])
|