diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2013-09-07 11:03:23 -0500 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2013-09-07 11:03:38 -0500 |
| commit | bacbbb481da8a582642a265459f2144db813dcee (patch) | |
| tree | 29cb2ece689590469eec7e1b10f8f60d8676a943 /tests | |
| parent | 9079436b0092db4a7e0031c27747d97f68b0fc5b (diff) | |
RunSQL migration operation and alpha SeparateDatabaseAndState op'n.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_operations.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 1bc4a42d7e..72f938fe4e 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -280,6 +280,32 @@ class OperationTests(MigrationTestBase): operation.database_backwards("test_alinto", editor, new_state, project_state) self.assertIndexNotExists("test_alinto_pony", ["pink", "weight"]) + def test_run_sql(self): + """ + Tests the AlterIndexTogether operation. + """ + project_state = self.set_up_test_model("test_runsql") + # Create the operation + operation = migrations.RunSQL( + "CREATE TABLE i_love_ponies (id int, special_thing int)", + "DROP TABLE i_love_ponies", + state_operations = [migrations.CreateModel("SomethingElse", [("id", models.AutoField(primary_key=True))])], + ) + # Test the state alteration + new_state = project_state.clone() + operation.state_forwards("test_runsql", new_state) + self.assertEqual(len(new_state.models["test_runsql", "somethingelse"].fields), 1) + # Make sure there's no table + self.assertTableNotExists("i_love_ponies") + # Test the database alteration + with connection.schema_editor() as editor: + operation.database_forwards("test_runsql", editor, project_state, new_state) + self.assertTableExists("i_love_ponies") + # And test reversal + with connection.schema_editor() as editor: + operation.database_backwards("test_runsql", editor, new_state, project_state) + self.assertTableNotExists("i_love_ponies") + class MigrateNothingRouter(object): """ |
