[svn] commit: r967 - in /trunk/src/lib/config/python/isc/config: config_data.py config_data_test.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Feb 25 17:49:39 UTC 2010
Author: jelte
Date: Thu Feb 25 17:49:39 2010
New Revision: 967
Log:
ok this is as far as i can get with coverage on config_data.py
Modified:
trunk/src/lib/config/python/isc/config/config_data.py
trunk/src/lib/config/python/isc/config/config_data_test.py
Modified: trunk/src/lib/config/python/isc/config/config_data.py
==============================================================================
--- trunk/src/lib/config/python/isc/config/config_data.py (original)
+++ trunk/src/lib/config/python/isc/config/config_data.py Thu Feb 25 17:49:39 2010
@@ -73,7 +73,7 @@
elif type(cur_el) == list:
found = False
for cur_el_item in cur_el:
- if cur_el_item['item_name'] == id and 'item_default' in cur_el_item.keys():
+ if cur_el_item['item_name'] == id:
cur_el = cur_el_item
found = True
if not found:
@@ -200,6 +200,11 @@
if type(spec) != isc.config.ModuleSpec:
raise ConfigDataError("not a datadef: " + str(type(spec)))
self._specifications[spec.get_module_name()] = spec
+
+ def remove_specification(self, module_name):
+ """Removes the specification with the given module name. Does nothing if it wasn't there."""
+ if module_name in self._specifications:
+ del self._specifications[module_name]
def get_module_spec(self, module):
"""Returns the ModuleSpec for the module with the given name.
@@ -344,13 +349,13 @@
else:
entry['default'] = False
result.append(entry)
- else:
+ elif type(spec_part) == dict:
item = spec_part
if item['item_type'] == 'list':
li_spec = item['list_item_spec']
- l, status = self.get_value("/" + identifier)
- if l:
- for value in l:
+ item_list, status = self.get_value("/" + identifier)
+ if item_list != None:
+ for value in item_list:
result_part2 = {}
result_part2['name'] = li_spec['item_name']
result_part2['value'] = value
Modified: trunk/src/lib/config/python/isc/config/config_data_test.py
==============================================================================
--- trunk/src/lib/config/python/isc/config/config_data_test.py (original)
+++ trunk/src/lib/config/python/isc/config/config_data_test.py Thu Feb 25 17:49:39 2010
@@ -297,6 +297,20 @@
self.assertEqual(MultiConfigData.NONE, status)
def test_get_value_maps(self):
+ maps = self.mcd.get_value_maps()
+ self.assertEqual([], maps)
+
+ module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec1.spec")
+ self.mcd.set_specification(module_spec)
+ maps = self.mcd.get_value_maps()
+ self.assertEqual([{'default': False, 'type': 'module', 'name': 'Spec1', 'value': None, 'modified': False}], maps)
+ maps = self.mcd.get_value_maps('Spec2')
+ self.assertEqual([], maps)
+ maps = self.mcd.get_value_maps('Spec1')
+ self.assertEqual([], maps)
+ self.mcd.remove_specification("Spec1")
+ self.mcd.remove_specification("foo")
+
module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec2.spec")
self.mcd.set_specification(module_spec)
maps = self.mcd.get_value_maps()
@@ -329,6 +343,15 @@
maps = self.mcd.get_value_maps("/Spec2/item4")
self.assertEqual([{'default': False, 'type': 'string', 'name': 'item4', 'value': 'test', 'modified': False}], maps)
+ module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec24.spec")
+ self.mcd.set_specification(module_spec)
+ maps = self.mcd.get_value_maps("/Spec24/item")
+ self.assertEqual([], maps)
+ self.mcd._set_current_config({ "Spec24": { "item": [] } })
+ maps = self.mcd.get_value_maps("/Spec24/item")
+ self.assertEqual([], maps)
+
+
def test_set_value(self):
module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec2.spec")
More information about the bind10-changes
mailing list