CreateModel honors multi-db settings.
(self, app_label, should_run)
| 45 | databases = {"default", "other"} |
| 46 | |
| 47 | def _test_create_model(self, app_label, should_run): |
| 48 | """ |
| 49 | CreateModel honors multi-db settings. |
| 50 | """ |
| 51 | operation = migrations.CreateModel( |
| 52 | "Pony", |
| 53 | [("id", models.AutoField(primary_key=True))], |
| 54 | ) |
| 55 | # Test the state alteration |
| 56 | project_state = ProjectState() |
| 57 | new_state = project_state.clone() |
| 58 | operation.state_forwards(app_label, new_state) |
| 59 | # Test the database alteration |
| 60 | self.assertTableNotExists("%s_pony" % app_label) |
| 61 | with connection.schema_editor() as editor: |
| 62 | operation.database_forwards(app_label, editor, project_state, new_state) |
| 63 | if should_run: |
| 64 | self.assertTableExists("%s_pony" % app_label) |
| 65 | else: |
| 66 | self.assertTableNotExists("%s_pony" % app_label) |
| 67 | # And test reversal |
| 68 | with connection.schema_editor() as editor: |
| 69 | operation.database_backwards(app_label, editor, new_state, project_state) |
| 70 | self.assertTableNotExists("%s_pony" % app_label) |
| 71 | |
| 72 | @override_settings(DATABASE_ROUTERS=[AgnosticRouter()]) |
| 73 | def test_create_model(self): |
no test coverage detected