renames dict_combine to dict_merge in network_common (#26073)
This commit is contained in:
parent
15beaed6bc
commit
b12ca95824
2 changed files with 5 additions and 5 deletions
|
@ -227,7 +227,7 @@ def dict_diff(base, comparable):
|
||||||
return updates
|
return updates
|
||||||
|
|
||||||
|
|
||||||
def dict_combine(base, other):
|
def dict_merge(base, other):
|
||||||
""" Return a new dict object that combines base and other
|
""" Return a new dict object that combines base and other
|
||||||
|
|
||||||
This will create a new dict object that is a combination of the key/value
|
This will create a new dict object that is a combination of the key/value
|
||||||
|
@ -250,7 +250,7 @@ def dict_combine(base, other):
|
||||||
if key in other:
|
if key in other:
|
||||||
item = other.get(key)
|
item = other.get(key)
|
||||||
if item is not None:
|
if item is not None:
|
||||||
combined[key] = dict_combine(value, other[key])
|
combined[key] = dict_merge(value, other[key])
|
||||||
else:
|
else:
|
||||||
combined[key] = item
|
combined[key] = item
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -24,7 +24,7 @@ __metaclass__ = type
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
|
|
||||||
from ansible.module_utils.network_common import to_list, sort_list
|
from ansible.module_utils.network_common import to_list, sort_list
|
||||||
from ansible.module_utils.network_common import dict_diff, dict_combine
|
from ansible.module_utils.network_common import dict_diff, dict_merge
|
||||||
|
|
||||||
|
|
||||||
class TestModuleUtilsNetworkCommon(unittest.TestCase):
|
class TestModuleUtilsNetworkCommon(unittest.TestCase):
|
||||||
|
@ -87,7 +87,7 @@ class TestModuleUtilsNetworkCommon(unittest.TestCase):
|
||||||
self.assertTrue(result['b3'])
|
self.assertTrue(result['b3'])
|
||||||
self.assertTrue(result['b4'])
|
self.assertTrue(result['b4'])
|
||||||
|
|
||||||
def test_dict_combine(self):
|
def test_dict_merge(self):
|
||||||
base = dict(obj2=dict(), b1=True, b2=False, b3=False,
|
base = dict(obj2=dict(), b1=True, b2=False, b3=False,
|
||||||
one=1, two=2, three=3, obj1=dict(key1=1, key2=2),
|
one=1, two=2, three=3, obj1=dict(key1=1, key2=2),
|
||||||
l1=[1, 3], l2=[1, 2, 3], l4=[4],
|
l1=[1, 3], l2=[1, 2, 3], l4=[4],
|
||||||
|
@ -98,7 +98,7 @@ class TestModuleUtilsNetworkCommon(unittest.TestCase):
|
||||||
l1=[2, 1], l2=[3, 2, 1], l3=[1],
|
l1=[2, 1], l2=[3, 2, 1], l3=[1],
|
||||||
nested=dict(n1=dict(n2=2, n3=3)))
|
nested=dict(n1=dict(n2=2, n3=3)))
|
||||||
|
|
||||||
result = dict_combine(base, other)
|
result = dict_merge(base, other)
|
||||||
|
|
||||||
# string assertions
|
# string assertions
|
||||||
self.assertIn('one', result)
|
self.assertIn('one', result)
|
||||||
|
|
Loading…
Reference in a new issue