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