mirror of
https://github.com/django/django.git
synced 2025-05-07 15:36:29 +00:00
Increased test coverage for django.db.migrations.operations.special.
This commit is contained in:
parent
07c8d979ae
commit
a2dcc4ecbb
@ -5115,6 +5115,15 @@ class OperationTests(OperationTestBase):
|
|||||||
collected_sql = "\n".join(editor.collected_sql)
|
collected_sql = "\n".join(editor.collected_sql)
|
||||||
self.assertEqual(collected_sql.count(";"), 1)
|
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):
|
def test_run_python(self):
|
||||||
"""
|
"""
|
||||||
Tests the RunPython operation
|
Tests the RunPython operation
|
||||||
@ -5238,6 +5247,11 @@ class OperationTests(OperationTestBase):
|
|||||||
elidable_operation = migrations.RunPython(inner_method, elidable=True)
|
elidable_operation = migrations.RunPython(inner_method, elidable=True)
|
||||||
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
|
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):
|
def test_run_python_atomic(self):
|
||||||
"""
|
"""
|
||||||
Tests the RunPython operation correctly handles the "atomic" keyword
|
Tests the RunPython operation correctly handles the "atomic" keyword
|
||||||
|
Loading…
x
Reference in New Issue
Block a user