Tests the DeleteModel operation.
(self)
| 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 | """ |
nothing calls this directly
no test coverage detected