MCPcopy
hub / github.com/django/django / test_delete_model

Method test_delete_model

tests/migrations/test_operations.py:707–733  ·  view source on GitHub ↗

Tests the DeleteModel operation.

(self)

Source from the content-addressed store, hash-verified

705 self.assertEqual(managers[2][1].args, ("x", "y", 3, 4))
706
707 def test_delete_model(self):
708 """
709 Tests the DeleteModel operation.
710 """
711 project_state = self.set_up_test_model("test_dlmo")
712 # Test the state alteration
713 operation = migrations.DeleteModel("Pony")
714 self.assertEqual(operation.describe(), "Delete model Pony")
715 self.assertEqual(operation.formatted_description(), "- Delete model Pony")
716 self.assertEqual(operation.migration_name_fragment, "delete_pony")
717 new_state = project_state.clone()
718 operation.state_forwards("test_dlmo", new_state)
719 self.assertNotIn(("test_dlmo", "pony"), new_state.models)
720 # Test the database alteration
721 self.assertTableExists("test_dlmo_pony")
722 with connection.schema_editor() as editor:
723 operation.database_forwards("test_dlmo", editor, project_state, new_state)
724 self.assertTableNotExists("test_dlmo_pony")
725 # And test reversal
726 with connection.schema_editor() as editor:
727 operation.database_backwards("test_dlmo", editor, new_state, project_state)
728 self.assertTableExists("test_dlmo_pony")
729 # And deconstruction
730 definition = operation.deconstruct()
731 self.assertEqual(definition[0], "DeleteModel")
732 self.assertEqual(definition[1], [])
733 self.assertEqual(list(definition[2]), ["name"])
734
735 def test_delete_proxy_model(self):
736 """

Callers

nothing calls this directly

Calls 11

describeMethod · 0.95
state_forwardsMethod · 0.95
database_forwardsMethod · 0.95
database_backwardsMethod · 0.95
deconstructMethod · 0.95
formatted_descriptionMethod · 0.80
schema_editorMethod · 0.80
set_up_test_modelMethod · 0.45
cloneMethod · 0.45
assertTableExistsMethod · 0.45
assertTableNotExistsMethod · 0.45

Tested by

no test coverage detected