summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-03-25 08:31:32 +0100
committerGitHub <noreply@github.com>2024-03-25 08:31:32 +0100
commita2dcc4ecbb9fb417f72af6dca20a5455f561e884 (patch)
tree93077c2fe84136d0180313fe46f67c737ab03854 /tests/migrations
parent07c8d979aecf5f1f71ce4f174369df39f24d24b3 (diff)
Increased test coverage for django.db.migrations.operations.special.
Diffstat (limited to 'tests/migrations')
-rw-r--r--tests/migrations/test_operations.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index b058543801..79519db0bc 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -5115,6 +5115,15 @@ class OperationTests(OperationTestBase):
collected_sql = "\n".join(editor.collected_sql)
self.assertEqual(collected_sql.count(";"), 1)
+ def test_run_sql_backward_reverse_sql_required(self):
+ operation = migrations.RunSQL(sql=migrations.RunSQL.noop)
+ msg = "You cannot reverse this operation"
+ with (
+ connection.schema_editor() as editor,
+ self.assertRaisesMessage(NotImplementedError, msg),
+ ):
+ operation.database_backwards("test_runsql", editor, None, None)
+
def test_run_python(self):
"""
Tests the RunPython operation
@@ -5238,6 +5247,11 @@ class OperationTests(OperationTestBase):
elidable_operation = migrations.RunPython(inner_method, elidable=True)
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
+ def test_run_python_invalid_reverse_code(self):
+ msg = "RunPython must be supplied with callable arguments"
+ with self.assertRaisesMessage(ValueError, msg):
+ migrations.RunPython(code=migrations.RunPython.noop, reverse_code="invalid")
+
def test_run_python_atomic(self):
"""
Tests the RunPython operation correctly handles the "atomic" keyword