Skip to content

Commit

Permalink
Increased test coverage for django.db.migrations.operations.special.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixxm committed Mar 25, 2024
1 parent 07c8d97 commit a2dcc4e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/migrations/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5115,6 +5115,15 @@ def test_run_sql_add_missing_semicolon_on_collect_sql(self):
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
Expand Down Expand Up @@ -5238,6 +5247,11 @@ def create_shetlandponies(models, schema_editor):
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
Expand Down

0 comments on commit a2dcc4e

Please sign in to comment.