MCPcopy
hub / github.com/django/django / test_delete_proxy_model

Method test_delete_proxy_model

tests/migrations/test_operations.py:735–759  ·  view source on GitHub ↗

Tests the DeleteModel operation ignores proxy models.

(self)

Source from the content-addressed store, hash-verified

733 self.assertEqual(list(definition[2]), ["name"])
734
735 def test_delete_proxy_model(self):
736 """
737 Tests the DeleteModel operation ignores proxy models.
738 """
739 project_state = self.set_up_test_model("test_dlprmo", proxy_model=True)
740 # Test the state alteration
741 operation = migrations.DeleteModel("ProxyPony")
742 new_state = project_state.clone()
743 operation.state_forwards("test_dlprmo", new_state)
744 self.assertIn(("test_dlprmo", "proxypony"), project_state.models)
745 self.assertNotIn(("test_dlprmo", "proxypony"), new_state.models)
746 # Test the database alteration
747 self.assertTableExists("test_dlprmo_pony")
748 self.assertTableNotExists("test_dlprmo_proxypony")
749 with connection.schema_editor() as editor:
750 operation.database_forwards("test_dlprmo", editor, project_state, new_state)
751 self.assertTableExists("test_dlprmo_pony")
752 self.assertTableNotExists("test_dlprmo_proxypony")
753 # And test reversal
754 with connection.schema_editor() as editor:
755 operation.database_backwards(
756 "test_dlprmo", editor, new_state, project_state
757 )
758 self.assertTableExists("test_dlprmo_pony")
759 self.assertTableNotExists("test_dlprmo_proxypony")
760
761 def test_delete_mti_model(self):
762 project_state = self.set_up_test_model("test_dlmtimo", mti_model=True)

Callers

nothing calls this directly

Calls 8

state_forwardsMethod · 0.95
database_forwardsMethod · 0.95
database_backwardsMethod · 0.95
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