Skip to content
Permalink
Browse files

[openwrt] Added 'config_value' identifier in utils.merge_list

  • Loading branch information
nemesisdesign committed Jan 24, 2017
1 parent 6f712d1 commit fcae96cdc4c20c6c938598b79897372e4c8eee3f
Showing with 43 additions and 1 deletion.
  1. +1 −1 netjsonconfig/utils.py
  2. +36 −0 tests/openwrt/test_default.py
  3. +6 −0 tests/test_utils.py
@@ -33,7 +33,7 @@ def merge_config(template, config):
return result


def merge_list(list1, list2, identifiers=['name', 'id']):
def merge_list(list1, list2, identifiers=['name', 'config_value', 'id']):
"""
Merges ``list2`` on top of ``list1``.
@@ -109,3 +109,39 @@ def test_warning(self):
]
})
self.assertEqual(o.render(), 'package luci\n')

def test_merge(self):
template = {
"luci": [
{
"config_name": "core",
"config_value": "main",
"number": 3,
"list": ["eth0"],
"some_value": True
}
]
}
config = {
"luci": [
{
"config_name": "core",
"config_value": "main",
"number": 4,
"list": ["wlan0"]
}
]
}
expected = {
"luci": [
{
"config_name": "core",
"config_value": "main",
"number": 4,
"list": ["eth0", "wlan0"],
"some_value": True
}
]
}
o = OpenWrt(config, templates=[template])
self.assertEqual(o.config, expected)
@@ -186,3 +186,9 @@ def test_merge_list_union_and_override(self):
{"id": "test1", "a": "0", "b": "b"},
{"id": "test2", "c": "c"}
])

def test_merge_list_config_value(self):
template = [{"config_value": "test1", "tx": 1}]
config = [{"config_value": "test1", "tx": 2}]
result = merge_list(template, config)
self.assertEqual(result, config)

0 comments on commit fcae96c

Please sign in to comment.
You can’t perform that action at this time.