CreateModel ignores proxy models.
(self)
| 371 | self.assertTableNotExists("test_crmoih_shetlandpony") |
| 372 | |
| 373 | def test_create_proxy_model(self): |
| 374 | """ |
| 375 | CreateModel ignores proxy models. |
| 376 | """ |
| 377 | project_state = self.set_up_test_model("test_crprmo") |
| 378 | # Test the state alteration |
| 379 | operation = migrations.CreateModel( |
| 380 | "ProxyPony", |
| 381 | [], |
| 382 | options={"proxy": True}, |
| 383 | bases=("test_crprmo.Pony",), |
| 384 | ) |
| 385 | self.assertEqual(operation.describe(), "Create proxy model ProxyPony") |
| 386 | new_state = project_state.clone() |
| 387 | operation.state_forwards("test_crprmo", new_state) |
| 388 | self.assertIn(("test_crprmo", "proxypony"), new_state.models) |
| 389 | # Test the database alteration |
| 390 | self.assertTableNotExists("test_crprmo_proxypony") |
| 391 | self.assertTableExists("test_crprmo_pony") |
| 392 | with connection.schema_editor() as editor: |
| 393 | operation.database_forwards("test_crprmo", editor, project_state, new_state) |
| 394 | self.assertTableNotExists("test_crprmo_proxypony") |
| 395 | self.assertTableExists("test_crprmo_pony") |
| 396 | # And test reversal |
| 397 | with connection.schema_editor() as editor: |
| 398 | operation.database_backwards( |
| 399 | "test_crprmo", editor, new_state, project_state |
| 400 | ) |
| 401 | self.assertTableNotExists("test_crprmo_proxypony") |
| 402 | self.assertTableExists("test_crprmo_pony") |
| 403 | # And deconstruction |
| 404 | definition = operation.deconstruct() |
| 405 | self.assertEqual(definition[0], "CreateModel") |
| 406 | self.assertEqual(definition[1], []) |
| 407 | self.assertEqual(sorted(definition[2]), ["bases", "fields", "name", "options"]) |
| 408 | |
| 409 | def test_create_unmanaged_model(self): |
| 410 | """ |
nothing calls this directly
no test coverage detected