summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/mergers/m_list.py7
-rw-r--r--tests/unittests/test_merging.py24
2 files changed, 29 insertions, 2 deletions
diff --git a/cloudinit/mergers/m_list.py b/cloudinit/mergers/m_list.py
index 50f279e8..34b32379 100644
--- a/cloudinit/mergers/m_list.py
+++ b/cloudinit/mergers/m_list.py
@@ -16,13 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+DEF_MERGE_TYPE = 'replace'
+MERGE_TYPES = ('append', 'prepend', DEF_MERGE_TYPE,)
+
class Merger(object):
def __init__(self, merger, opts):
self._merger = merger
# Affects merging behavior...
- self._method = 'replace'
- for m in ['append', 'prepend', 'replace']:
+ self._method = DEF_MERGE_TYPE
+ for m in MERGE_TYPES:
if m in opts:
self._method = m
break
diff --git a/tests/unittests/test_merging.py b/tests/unittests/test_merging.py
index f83522d7..cff8ac12 100644
--- a/tests/unittests/test_merging.py
+++ b/tests/unittests/test_merging.py
@@ -119,6 +119,30 @@ class TestSimpleRun(helpers.ResourceUsingTestCase):
'1': '2',
'b': {
'f': 'g',
+ 'e': 'c',
+ 'h': 'd',
+ 'hh': {
+ '1': 2,
+ },
+ }
+ }
+ b = {
+ 'b': {
+ 'e': 'c',
+ 'hh': {
+ '3': 4,
+ }
+ }
+ }
+ c = _old_mergedict(a, b)
+ d = util.mergemanydict([a, b])
+ self.assertEquals(c, d)
+
+ def test_compat_merge_sub_dict2(self):
+ a = {
+ '1': '2',
+ 'b': {
+ 'f': 'g',
}
}
b = {