Skip to content

Commit fae35a5

Browse files
committed
added test for renaming tables in SchemaSnapshot
1 parent 86b876a commit fae35a5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/apps/migrations/auto/test_schema_snapshot.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ def test_drop_table(self):
4242
class_names = [i.class_name for i in snapshot]
4343
self.assertTrue("Manager" in class_names)
4444

45+
def test_rename_table(self):
46+
"""
47+
Test renaming tables.
48+
"""
49+
manager_1 = MigrationManager()
50+
manager_1.add_table(class_name="Band", tablename="band")
51+
52+
manager_2 = MigrationManager()
53+
manager_2.rename_table(
54+
old_class_name="Band",
55+
old_tablename="band",
56+
new_class_name="Performer",
57+
new_tablename="performer",
58+
)
59+
60+
schema_snapshot = SchemaSnapshot(managers=[manager_1, manager_2])
61+
snapshot = schema_snapshot.get_snapshot()
62+
63+
self.assertTrue(snapshot[0].class_name == "Performer")
64+
self.assertTrue(snapshot[0].tablename == "performer")
65+
4566
def test_add_column(self):
4667
"""
4768
Test adding columns.

0 commit comments

Comments
 (0)