Commit 5a7c1928 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[trac670] Test config handler

parent f9a697ab
......@@ -510,7 +510,8 @@ class MyZonemgr(Zonemgr):
"lowerbound_refresh" : 10,
"lowerbound_retry" : 5,
"max_transfer_timeout" : 14400,
"jitter_scope" : 0.1
"jitter_scope" : 0.1,
"secondary_zones": []
}
def _start_zone_refresh_timer(self):
......@@ -526,7 +527,8 @@ class TestZonemgr(unittest.TestCase):
"lowerbound_refresh" : 60,
"lowerbound_retry" : 30,
"max_transfer_timeout" : 14400,
"jitter_scope" : 0.1
"jitter_scope" : 0.1,
"secondary_zones": []
}
self.zonemgr.config_handler(config_data1)
self.assertEqual(config_data1, self.zonemgr._config_data)
......@@ -537,6 +539,15 @@ class TestZonemgr(unittest.TestCase):
config_data3 = {"jitter_scope" : 0.7}
self.zonemgr.config_handler(config_data3)
self.assertEqual(0.5, self.zonemgr._config_data.get("jitter_scope"))
# The zone doesn't exist in database, it should be rejected
self.zonemgr._zone_refresh = ZonemgrRefresh(None, "initdb.file", None,
config_data1)
config_data1["secondary_zones"] = [{"name": "nonexistent.example",
"class": "IN"}]
self.assertNotEqual(self.zonemgr.config_handler(config_data1),
{"result": [0]})
# As it is rejected, the old value should be kept
self.assertEqual(0.5, self.zonemgr._config_data.get("jitter_scope"))
def test_get_db_file(self):
self.assertEqual("initdb.file", self.zonemgr.get_db_file())
......
......@@ -102,8 +102,8 @@ class ZonemgrRefresh:
self._cc = cc
self._check_sock = slave_socket
self._db_file = db_file
self.update_config_data(config_data)
self._zonemgr_refresh_info = {}
self.update_config_data(config_data)
self._build_zonemgr_refresh_info()
self._running = False
......@@ -497,7 +497,7 @@ class Zonemgr:
self._config_data[key] = new_config[key]
self._config_data_check(self._config_data)
if (self._zone_refresh):
if self._zone_refresh is not None:
self._zone_refresh.update_config_data(self._config_data)
return answer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment