Skip to content

Commit

Permalink
[tests] Added test_override
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jun 6, 2017
1 parent e02d79a commit 87b6250
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion netjsonconfig/backends/base/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _merge_config(self, config, templates):
raise TypeError('templates argument must be an instance of list')
# merge templates with main configuration
result = {}
config_list = [config] + templates
config_list = templates + [config]
for merging in config_list:
result = merge_config(result, self._load(merging), self.list_identifiers)
return result
Expand Down
22 changes: 22 additions & 0 deletions tests/openwrt/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,25 @@ def test_checksum(self):
sleep(1)
checksum2 = md5(o.generate().getvalue()).hexdigest()
self.assertEqual(checksum1, checksum2)

def test_override(self):
config = {
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"disabled": False
}
]
}
template = {
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"disabled": True
}
]
}
o = OpenWrt(config, templates=[template])
self.assertFalse(o.config['interfaces'][0]['disabled'])

0 comments on commit 87b6250

Please sign in to comment.