0
0
mirror of https://github.com/django/django.git synced 2024-11-28 21:43:13 +01:00

Increased test coverage for django.db.migrations.operations.special.

This commit is contained in:
Mariusz Felisiak 2024-03-25 08:31:32 +01:00 committed by GitHub
parent 07c8d979ae
commit a2dcc4ecbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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