Skip to content

Commit

Permalink
Add tests for the ddns settings
Browse files Browse the repository at this point in the history
  • Loading branch information
okraits committed Nov 15, 2018
1 parent c43c7fe commit a869f14
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
3 changes: 1 addition & 2 deletions netjsonconfig/backends/openwrt/converters/ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def __intermediate_providers(self, providers):
uci_name = self._get_uci_name(provider['lookup_host'])
resultdict = OrderedDict((('.name', uci_name),
('.type', 'service')))
for key, value in provider.items():
resultdict[key] = value
resultdict.update(provider)
result.append(resultdict)
return result

Expand Down
37 changes: 37 additions & 0 deletions tests/openwrt/test_ddns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import unittest

from netjsonconfig import OpenWrt
from netjsonconfig.utils import _TabsMixin


class TestDdns(unittest.TestCase, _TabsMixin):
maxDiff = None
_ddns_netjson_global = {
"ddns": {
"ddns_dateformat": "%F %R",
"ddns_logdir": "/var/log/ddns",
"ddns_loglines": 250,
"ddns_rundir": "/var/run/ddns",
"upd_privateip": False,
"use_curl": False
}
}
_ddns_uci_global = """package ddns
config ddns 'global'
option ddns_dateformat '%F %R'
option ddns_logdir '/var/log/ddns'
option ddns_loglines '250'
option ddns_rundir '/var/run/ddns'
option upd_privateip '0'
option use_curl '0'
"""

def test_render_ddns_global(self):
o = OpenWrt(self._ddns_netjson_global)
expected = self._tabs(self._ddns_uci_global)
self.assertEqual(o.render(), expected)

def test_parse_ddns_global(self):
o = OpenWrt(native=self._ddns_uci_global)
self.assertDictEqual(o.config, self._ddns_netjson_global)

0 comments on commit a869f14

Please sign in to comment.