2015-01-28 20:35:27 +08:00
|
|
|
from django.test import TestCase, TransactionTestCase
|
|
|
|
|
2014-06-09 10:30:15 +08:00
|
|
|
from .models import Book
|
|
|
|
|
|
|
|
|
|
|
|
class MigrationDataPersistenceTestCase(TransactionTestCase):
|
|
|
|
"""
|
2016-10-27 15:53:39 +08:00
|
|
|
Data loaded in migrations is available if
|
|
|
|
TransactionTestCase.serialized_rollback = True.
|
2014-06-09 10:30:15 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
available_apps = ["migration_test_data_persistence"]
|
|
|
|
serialized_rollback = True
|
|
|
|
|
|
|
|
def test_persistence(self):
|
|
|
|
self.assertEqual(
|
|
|
|
Book.objects.count(),
|
|
|
|
1,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-06-24 11:25:09 +08:00
|
|
|
class MigrationDataNormalPersistenceTestCase(TestCase):
|
2014-06-09 10:30:15 +08:00
|
|
|
"""
|
2016-10-27 15:53:39 +08:00
|
|
|
Data loaded in migrations is available on TestCase
|
2014-06-09 10:30:15 +08:00
|
|
|
"""
|
|
|
|
|
2014-06-24 11:25:09 +08:00
|
|
|
def test_persistence(self):
|
2014-06-09 10:30:15 +08:00
|
|
|
self.assertEqual(
|
|
|
|
Book.objects.count(),
|
2014-06-24 11:25:09 +08:00
|
|
|
1,
|
2014-06-09 10:30:15 +08:00
|
|
|
)
|