summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarten Kenbeek <marten.knbk@gmail.com>2015-04-05 15:59:23 +0200
committerMarkus Holtermann <info@markusholtermann.eu>2015-04-05 20:29:27 +0200
commit773387ce42de1c355e6ed6b9ddd49dc52474fc0a (patch)
treefa7b74195b4ecd69c6e6ddba54ff994aef835f0d /tests
parent651cc369ad803e116268c5ec7f0f8389858ae10b (diff)
[1.8.x] Fixed #24278 -- Fixed serialization of migration operations.
Fixed MigrationWriter.serialize() to correctly handle migration operations by utilizing OperationWriter. Thanks Piotr MaliƄski for the report. Backport of e8e4f978dd4b7a3d0c689c6e3301e3c6f9e50003 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_writer.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index b60d6e79da..a6527caea4 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -81,6 +81,27 @@ class OperationWriterTests(SimpleTestCase):
'),'
)
+ def test_nested_args_signature(self):
+ operation = custom_migration_operations.operations.ArgsOperation(
+ custom_migration_operations.operations.ArgsOperation(1, 2),
+ custom_migration_operations.operations.KwargsOperation(kwarg1=3, kwarg2=4)
+ )
+ buff, imports = OperationWriter(operation, indentation=0).serialize()
+ self.assertEqual(imports, {'import custom_migration_operations.operations'})
+ self.assertEqual(
+ buff,
+ 'custom_migration_operations.operations.ArgsOperation(\n'
+ ' arg1=custom_migration_operations.operations.ArgsOperation(\n'
+ ' arg1=1,\n'
+ ' arg2=2,\n'
+ ' ),\n'
+ ' arg2=custom_migration_operations.operations.KwargsOperation(\n'
+ ' kwarg1=3,\n'
+ ' kwarg2=4,\n'
+ ' ),\n'
+ '),'
+ )
+
def test_multiline_args_signature(self):
operation = custom_migration_operations.operations.ArgsOperation("test\n arg1", "test\narg2")
buff, imports = OperationWriter(operation, indentation=0).serialize()
@@ -107,6 +128,29 @@ class OperationWriterTests(SimpleTestCase):
'),'
)
+ def test_nested_operation_expand_args_signature(self):
+ operation = custom_migration_operations.operations.ExpandArgsOperation(
+ arg=[
+ custom_migration_operations.operations.KwargsOperation(
+ kwarg1=1,
+ kwarg2=2,
+ ),
+ ]
+ )
+ buff, imports = OperationWriter(operation, indentation=0).serialize()
+ self.assertEqual(imports, {'import custom_migration_operations.operations'})
+ self.assertEqual(
+ buff,
+ 'custom_migration_operations.operations.ExpandArgsOperation(\n'
+ ' arg=[\n'
+ ' custom_migration_operations.operations.KwargsOperation(\n'
+ ' kwarg1=1,\n'
+ ' kwarg2=2,\n'
+ ' ),\n'
+ ' ],\n'
+ '),'
+ )
+
class WriterTests(TestCase):
"""