summaryrefslogtreecommitdiff
path: root/tests/migration_test_data_persistence/tests.py
blob: 1b89c17b8b41673fc1f0c74289d866fab327578e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from django.test import TransactionTestCase
from .models import Book


class MigrationDataPersistenceTestCase(TransactionTestCase):
    """
    Tests that data loaded in migrations is available if we set
    serialized_rollback = True.
    """

    available_apps = ["migration_test_data_persistence"]
    serialized_rollback = True

    def test_persistence(self):
        self.assertEqual(
            Book.objects.count(),
            1,
        )


class MigrationDataNoPersistenceTestCase(TransactionTestCase):
    """
    Tests the failure case
    """

    available_apps = ["migration_test_data_persistence"]
    serialized_rollback = False

    def test_no_persistence(self):
        self.assertEqual(
            Book.objects.count(),
            0,
        )