diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-05-03 14:46:52 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-05-03 14:46:52 -0700 |
commit | c972396ecccb4b67eafc038a482ffeaa1df2c93e (patch) | |
tree | c21c284291916a74c7187b3b8b112085947e5f9e | |
parent | 4a669649b17cf01b6f89f7902b6683d02ef0bee1 (diff) | |
download | vyos-cloud-init-c972396ecccb4b67eafc038a482ffeaa1df2c93e.tar.gz vyos-cloud-init-c972396ecccb4b67eafc038a482ffeaa1df2c93e.zip |
A few more tests + cleanings.
-rw-r--r-- | cloudinit/mergers/m_list.py | 7 | ||||
-rw-r--r-- | tests/unittests/test_merging.py | 24 |
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 = { |