2014-06-24 11:25:09 +08:00
|
|
|
from django.test import TransactionTestCase, TestCase
|
2014-06-09 10:30:15 +08:00
|
|
|
from .models import Book
|
|
|
|
|
|
|
|
|
|
|
|
class MigrationDataPersistenceTestCase(TransactionTestCase):
|
|
|
|
"""
|
|
|
|
Tests that data loaded in migrations is available if we set
|
2014-06-24 11:25:09 +08:00
|
|
|
serialized_rollback = True on TransactionTestCase
|
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
|
|
|
"""
|
2014-06-24 11:25:09 +08:00
|
|
|
Tests that 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
|
|
|
)
|