summaryrefslogtreecommitdiff
path: root/tests/migration_test_data_persistence/tests.py
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-06-08 19:30:15 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-06-08 19:33:52 -0700
commit08218252d8be4633ac0e94863da527d824648d63 (patch)
tree7b2724bc7730960af1ba7b539192132ccae2f50c /tests/migration_test_data_persistence/tests.py
parentbf019c977055ade45c5c260ed235bb5dcf7e2be7 (diff)
[1.7.x] Fixed #22487: Optional rollback emulation for migrated apps
Conflicts: django/db/backends/creation.py django/test/runner.py docs/ref/settings.txt docs/topics/testing/advanced.txt
Diffstat (limited to 'tests/migration_test_data_persistence/tests.py')
-rw-r--r--tests/migration_test_data_persistence/tests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/migration_test_data_persistence/tests.py b/tests/migration_test_data_persistence/tests.py
new file mode 100644
index 0000000000..1b89c17b8b
--- /dev/null
+++ b/tests/migration_test_data_persistence/tests.py
@@ -0,0 +1,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,
+ )