mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Updates list merge tests to check for sorted, unique lists
This commit is contained in:
parent
74bf91f99e
commit
18eda7084c
@ -39,7 +39,15 @@ class UtilDictupdateTestCase(TestCase):
|
||||
mdict['A'] = [1, 2]
|
||||
res = dictupdate.update(copy.deepcopy(mdict), {'A': [3, 4]},
|
||||
merge_lists=True)
|
||||
mdict['A'] = [1, 2, 3, 4]
|
||||
mdict['A'] = sorted([1, 2, 3, 4])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# level 1 value changes (list merge, remove duplicates)
|
||||
mdict = copy.deepcopy(self.dict1)
|
||||
mdict['A'] = [1, 2]
|
||||
res = dictupdate.update(copy.deepcopy(mdict), {'A': [1, 2, 3, 4]},
|
||||
merge_lists=True)
|
||||
mdict['A'] = sorted([1, 2, 3, 4])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# level 2 value changes
|
||||
@ -61,7 +69,16 @@ class UtilDictupdateTestCase(TestCase):
|
||||
mdict['C']['D'] = ['a', 'b']
|
||||
res = dictupdate.update(copy.deepcopy(mdict), {'C': {'D': ['c', 'd']}},
|
||||
merge_lists=True)
|
||||
mdict['C']['D'] = ['a', 'b', 'c', 'd']
|
||||
mdict['C']['D'] = sorted(['a', 'b', 'c', 'd'])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# level 2 value changes (list merge, remove duplicates)
|
||||
mdict = copy.deepcopy(self.dict1)
|
||||
mdict['C']['D'] = ['a', 'b']
|
||||
res = dictupdate.update(copy.deepcopy(mdict),
|
||||
{'C': {'D': ['a', 'b', 'c', 'd']}},
|
||||
merge_lists=True)
|
||||
mdict['C']['D'] = sorted(['a', 'b', 'c', 'd'])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# level 3 value changes
|
||||
@ -86,7 +103,15 @@ class UtilDictupdateTestCase(TestCase):
|
||||
mdict['C']['F']['G'] = ['a', 'b']
|
||||
res = dictupdate.update(copy.deepcopy(mdict),
|
||||
{'C': {'F': {'G': ['c', 'd']}}}, merge_lists=True)
|
||||
mdict['C']['F']['G'] = ['a', 'b', 'c', 'd']
|
||||
mdict['C']['F']['G'] = sorted(['a', 'b', 'c', 'd'])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# level 3 value changes (list merge, remove duplicates)
|
||||
mdict = copy.deepcopy(self.dict1)
|
||||
mdict['C']['F']['G'] = ['a', 'b']
|
||||
res = dictupdate.update(copy.deepcopy(mdict),
|
||||
{'C': {'F': {'G': ['a', 'b', 'c', 'd']}}}, merge_lists=True)
|
||||
mdict['C']['F']['G'] = sorted(['a', 'b', 'c', 'd'])
|
||||
self.assertEqual(res, mdict)
|
||||
|
||||
# replace a sub-dictionary
|
||||
|
Loading…
Reference in New Issue
Block a user