diff options
| author | Simon Charette <charettes@users.noreply.github.com> | 2018-07-25 12:07:42 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-07-25 12:07:41 -0400 |
| commit | dc1dcad0f54677bfdbcf187bbcb8eca5f73b6fca (patch) | |
| tree | 40dd9dcdc7fb93ea0f28b1875c0aa14f2facee75 /tests/migrations/test_operations.py | |
| parent | ac25dd1f8d48accc765c05aebb47c427e51f3255 (diff) | |
Refs #24424 -- Added regression tests for MTI-inheritance model removal.
The issue was fixed as a side effect of implementing RemoveField's reduction
of DeleteModel to a DeleteModel in ad82900ad94ed4bbad050b9993373dafbe66b610.
Diffstat (limited to 'tests/migrations/test_operations.py')
| -rw-r--r-- | tests/migrations/test_operations.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 142330127b..9da67fad7f 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -588,6 +588,29 @@ class OperationTests(OperationTestBase): self.assertTableExists("test_dlprmo_pony") self.assertTableNotExists("test_dlprmo_proxypony") + def test_delete_mti_model(self): + project_state = self.set_up_test_model('test_dlmtimo', mti_model=True) + # Test the state alteration + operation = migrations.DeleteModel('ShetlandPony') + new_state = project_state.clone() + operation.state_forwards('test_dlmtimo', new_state) + self.assertIn(('test_dlmtimo', 'shetlandpony'), project_state.models) + self.assertNotIn(('test_dlmtimo', 'shetlandpony'), new_state.models) + # Test the database alteration + self.assertTableExists('test_dlmtimo_pony') + self.assertTableExists('test_dlmtimo_shetlandpony') + self.assertColumnExists('test_dlmtimo_shetlandpony', 'pony_ptr_id') + with connection.schema_editor() as editor: + operation.database_forwards('test_dlmtimo', editor, project_state, new_state) + self.assertTableExists('test_dlmtimo_pony') + self.assertTableNotExists('test_dlmtimo_shetlandpony') + # And test reversal + with connection.schema_editor() as editor: + operation.database_backwards('test_dlmtimo', editor, new_state, project_state) + self.assertTableExists('test_dlmtimo_pony') + self.assertTableExists('test_dlmtimo_shetlandpony') + self.assertColumnExists('test_dlmtimo_shetlandpony', 'pony_ptr_id') + def test_rename_model(self): """ Tests the RenameModel operation. |
