diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2012-08-10 15:03:18 +0100 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2012-08-10 15:03:18 +0100 |
| commit | 60873ea2ade8bed909b9f2dabb0f8a499226e10d (patch) | |
| tree | 1b77b20bc634dfee5611882b5903da8618c750ac /tests | |
| parent | 184cf9ab798d5b25d855649ddb2ca580949778df (diff) | |
Add db_table and db_tablespace handling
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/schema/tests.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/modeltests/schema/tests.py b/tests/modeltests/schema/tests.py index 52d99225f0..8813d3ca23 100644 --- a/tests/modeltests/schema/tests.py +++ b/tests/modeltests/schema/tests.py @@ -342,3 +342,42 @@ class SchemaTests(TestCase): UniqueTest.objects.create(year=2012, slug="foo") self.assertRaises(IntegrityError, UniqueTest.objects.create, year=2012, slug="foo") connection.rollback() + + def test_db_table(self): + """ + Tests renaming of the table + """ + # Create the table + editor = connection.schema_editor() + editor.start() + editor.create_model(Author) + editor.commit() + # Ensure the table is there to begin with + columns = self.column_classes(Author) + self.assertEqual(columns['name'][0], "CharField") + # Alter the table + editor = connection.schema_editor() + editor.start() + editor.alter_db_table( + Author, + "schema_author", + "schema_otherauthor", + ) + editor.commit() + # Ensure the table is there afterwards + Author._meta.db_table = "schema_otherauthor" + columns = self.column_classes(Author) + self.assertEqual(columns['name'][0], "CharField") + # Alter the table again + editor = connection.schema_editor() + editor.start() + editor.alter_db_table( + Author, + "schema_otherauthor", + "schema_author", + ) + editor.commit() + # Ensure the table is still there + Author._meta.db_table = "schema_author" + columns = self.column_classes(Author) + self.assertEqual(columns['name'][0], "CharField") |
