summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorAmir Karimi <amk9978@gmail.com>2023-09-16 05:41:22 +0330
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-01-17 14:00:02 +0100
commit27a3eee72170f1eb994a213db985f42c6cf5f994 (patch)
treed3522cf986d3ce3c1147063c5dbd1805c95843fa /tests/postgres_tests
parentc7e986fc9f4848bd757d4b9b70a40586d2cee9fb (diff)
Fixed #31700 -- Made makemigrations command display meaningful symbols for each operation.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_operations.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_operations.py b/tests/postgres_tests/test_operations.py
index f395198533..ff344e3cb0 100644
--- a/tests/postgres_tests/test_operations.py
+++ b/tests/postgres_tests/test_operations.py
@@ -59,6 +59,10 @@ class AddIndexConcurrentlyTests(OperationTestBase):
operation.describe(),
"Concurrently create index pony_pink_idx on field(s) pink of model Pony",
)
+ self.assertEqual(
+ operation.formatted_description(),
+ "+ Concurrently create index pony_pink_idx on field(s) pink of model Pony",
+ )
operation.state_forwards(self.app_label, new_state)
self.assertEqual(
len(new_state.models[self.app_label, "pony"].options["indexes"]), 1
@@ -154,6 +158,10 @@ class RemoveIndexConcurrentlyTests(OperationTestBase):
operation.describe(),
"Concurrently remove index pony_pink_idx from Pony",
)
+ self.assertEqual(
+ operation.formatted_description(),
+ "- Concurrently remove index pony_pink_idx from Pony",
+ )
operation.state_forwards(self.app_label, new_state)
self.assertEqual(
len(new_state.models[self.app_label, "pony"].options["indexes"]), 0
@@ -190,6 +198,9 @@ class CreateExtensionTests(PostgreSQLTestCase):
@override_settings(DATABASE_ROUTERS=[NoMigrationRouter()])
def test_no_allow_migrate(self):
operation = CreateExtension("tablefunc")
+ self.assertEqual(
+ operation.formatted_description(), "+ Creates extension tablefunc"
+ )
project_state = ProjectState()
new_state = project_state.clone()
# Don't create an extension.
@@ -287,6 +298,7 @@ class CreateCollationTests(PostgreSQLTestCase):
operation = CreateCollation("C_test", locale="C")
self.assertEqual(operation.migration_name_fragment, "create_collation_c_test")
self.assertEqual(operation.describe(), "Create collation C_test")
+ self.assertEqual(operation.formatted_description(), "+ Create collation C_test")
project_state = ProjectState()
new_state = project_state.clone()
# Create a collation.
@@ -418,6 +430,7 @@ class RemoveCollationTests(PostgreSQLTestCase):
operation = RemoveCollation("C_test", locale="C")
self.assertEqual(operation.migration_name_fragment, "remove_collation_c_test")
self.assertEqual(operation.describe(), "Remove collation C_test")
+ self.assertEqual(operation.formatted_description(), "- Remove collation C_test")
project_state = ProjectState()
new_state = project_state.clone()
# Remove a collation.
@@ -471,6 +484,10 @@ class AddConstraintNotValidTests(OperationTestBase):
f"Create not valid constraint {constraint_name} on model Pony",
)
self.assertEqual(
+ operation.formatted_description(),
+ f"+ Create not valid constraint {constraint_name} on model Pony",
+ )
+ self.assertEqual(
operation.migration_name_fragment,
f"pony_{constraint_name}_not_valid",
)
@@ -531,6 +548,10 @@ class ValidateConstraintTests(OperationTestBase):
f"Validate constraint {constraint_name} on model Pony",
)
self.assertEqual(
+ operation.formatted_description(),
+ f"~ Validate constraint {constraint_name} on model Pony",
+ )
+ self.assertEqual(
operation.migration_name_fragment,
f"pony_validate_{constraint_name}",
)