From 9ce2c312b0ce20bde042e140da05cd71a0e14e73 Mon Sep 17 00:00:00 2001 From: Oliver Kraitschy Date: Fri, 13 Jul 2018 14:54:15 +0200 Subject: [PATCH] Add tests for the ddns settings --- tests/openwrt/test_ddns.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/openwrt/test_ddns.py diff --git a/tests/openwrt/test_ddns.py b/tests/openwrt/test_ddns.py new file mode 100644 index 000000000..babf31dbe --- /dev/null +++ b/tests/openwrt/test_ddns.py @@ -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)