2015-02-09 18:19:34 +00:00
|
|
|
from django.test import TestCase, TransactionTestCase
|
|
|
|
|
2014-06-09 02:30:15 +00:00
|
|
|
from .models import Book
|
|
|
|
|
|
|
|
|
|
|
|
class MigrationDataPersistenceTestCase(TransactionTestCase):
|
|
|
|
"""
|
|
|
|
Tests that data loaded in migrations is available if we set
|
2014-06-24 03:25:09 +00:00
|
|
|
serialized_rollback = True on TransactionTestCase
|
2014-06-09 02:30:15 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
available_apps = ["migration_test_data_persistence"]
|
|
|
|
serialized_rollback = True
|
|
|
|
|
|
|
|
def test_persistence(self):
|
|
|
|
self.assertEqual(
|
|
|
|
Book.objects.count(),
|
|
|
|
1,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-06-24 03:25:09 +00:00
|
|
|
class MigrationDataNormalPersistenceTestCase(TestCase):
|
2014-06-09 02:30:15 +00:00
|
|
|
"""
|
2014-06-24 03:25:09 +00:00
|
|
|
Tests that data loaded in migrations is available on TestCase
|
2014-06-09 02:30:15 +00:00
|
|
|
"""
|
|
|
|
|
2014-06-24 03:25:09 +00:00
|
|
|
def test_persistence(self):
|
2014-06-09 02:30:15 +00:00
|
|
|
self.assertEqual(
|
|
|
|
Book.objects.count(),
|
2014-06-24 03:25:09 +00:00
|
|
|
1,
|
2014-06-09 02:30:15 +00:00
|
|
|
)
|