diff options
author | Markus Holtermann <info@markusholtermann.eu> | 2015-01-07 21:10:56 +0100 |
---|---|---|
committer | Carl Meyer <carl@oddbird.net> | 2015-01-07 17:29:20 -0700 |
commit | 862ea825b5073588efafd5b7eed349ad098b5fe1 (patch) | |
tree | 5b934572778b21084ee3676f92dca48a7f17faf4 /tests/custom_migration_operations | |
parent | f487a3275ebb786d3e7716e1ed9cc994bd092f34 (diff) | |
download | django-862ea825b5073588efafd5b7eed349ad098b5fe1.tar.gz |
Fixed #24093 -- Prevented MigrationWriter to write operation kwargs that are not explicitly deconstructed
Diffstat (limited to 'tests/custom_migration_operations')
-rw-r--r-- | tests/custom_migration_operations/operations.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/custom_migration_operations/operations.py b/tests/custom_migration_operations/operations.py index 3a4127d753..bd62280f81 100644 --- a/tests/custom_migration_operations/operations.py +++ b/tests/custom_migration_operations/operations.py @@ -31,3 +31,64 @@ class TestOperation(Operation): class CreateModel(TestOperation): pass + + +class ArgsOperation(TestOperation): + def __init__(self, arg1, arg2): + self.arg1, self.arg2 = arg1, arg2 + + def deconstruct(self): + return ( + self.__class__.__name__, + [self.arg1, self.arg2], + {} + ) + + +class KwargsOperation(TestOperation): + def __init__(self, kwarg1=None, kwarg2=None): + self.kwarg1, self.kwarg2 = kwarg1, kwarg2 + + def deconstruct(self): + kwargs = {} + if self.kwarg1 is not None: + kwargs['kwarg1'] = self.kwarg1 + if self.kwarg2 is not None: + kwargs['kwarg2'] = self.kwarg2 + return ( + self.__class__.__name__, + [], + kwargs + ) + + +class ArgsKwargsOperation(TestOperation): + def __init__(self, arg1, arg2, kwarg1=None, kwarg2=None): + self.arg1, self.arg2 = arg1, arg2 + self.kwarg1, self.kwarg2 = kwarg1, kwarg2 + + def deconstruct(self): + kwargs = {} + if self.kwarg1 is not None: + kwargs['kwarg1'] = self.kwarg1 + if self.kwarg2 is not None: + kwargs['kwarg2'] = self.kwarg2 + return ( + self.__class__.__name__, + [self.arg1, self.arg2], + kwargs, + ) + + +class ExpandArgsOperation(TestOperation): + serialization_expand_args = ['arg'] + + def __init__(self, arg): + self.arg = arg + + def deconstruct(self): + return ( + self.__class__.__name__, + [self.arg], + {} + ) |