[svn] commit: r3757 - in /branches/trac202/src/lib/python/isc/config: config_data.py tests/config_data_test.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Dec 7 14:52:45 UTC 2010
Author: jelte
Date: Tue Dec 7 14:52:45 2010
New Revision: 3757
Log:
return an error in bindctl on 'config set' for an item not described in the .spec file
Modified:
branches/trac202/src/lib/python/isc/config/config_data.py
branches/trac202/src/lib/python/isc/config/tests/config_data_test.py
Modified: branches/trac202/src/lib/python/isc/config/config_data.py
==============================================================================
--- branches/trac202/src/lib/python/isc/config/config_data.py (original)
+++ branches/trac202/src/lib/python/isc/config/config_data.py Tue Dec 7 14:52:45 2010
@@ -464,12 +464,15 @@
there is a specification for the given identifier, the type
is checked."""
spec_part = self.find_spec_part(identifier)
- if spec_part is not None and value is not None:
- id, list_indices = isc.cc.data.split_identifier_list_indices(identifier)
- if list_indices is not None \
- and spec_part['item_type'] == 'list':
- spec_part = spec_part['list_item_spec']
- check_type(spec_part, value)
+ if spec_part is not None:
+ if value is not None:
+ id, list_indices = isc.cc.data.split_identifier_list_indices(identifier)
+ if list_indices is not None \
+ and spec_part['item_type'] == 'list':
+ spec_part = spec_part['list_item_spec']
+ check_type(spec_part, value)
+ else:
+ raise isc.cc.data.DataNotFoundError(identifier)
# Since we do not support list diffs (yet?), we need to
# copy the currently set list of items to _local_changes
Modified: branches/trac202/src/lib/python/isc/config/tests/config_data_test.py
==============================================================================
--- branches/trac202/src/lib/python/isc/config/tests/config_data_test.py (original)
+++ branches/trac202/src/lib/python/isc/config/tests/config_data_test.py Tue Dec 7 14:52:45 2010
@@ -335,6 +335,8 @@
pass
def test_get_local_value(self):
+ module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec2.spec")
+ self.mcd.set_specification(module_spec)
value = self.mcd.get_local_value("Spec2/item1")
self.assertEqual(None, value)
self.mcd.set_value("Spec2/item1", 2)
@@ -464,12 +466,11 @@
module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec2.spec")
self.mcd.set_specification(module_spec)
self.mcd.set_value("Spec2/item1", 2)
- self.assertRaises(isc.cc.data.DataTypeError, self.mcd.set_value, "Spec2/item1", "asdf")
-
- self.mcd.set_value("Spec2/no_such_item", 4)
- value, status = self.mcd.get_value("Spec2/no_such_item")
- self.assertEqual(value, 4)
- self.assertEqual(MultiConfigData.LOCAL, status)
+ self.assertRaises(isc.cc.data.DataTypeError,
+ self.mcd.set_value, "Spec2/item1", "asdf")
+
+ self.assertRaises(isc.cc.data.DataNotFoundError,
+ self.mcd.set_value, "Spec2/no_such_item", 4)
self.mcd.set_value("Spec2/item5[0]", "c")
value, status = self.mcd.get_value("Spec2/item5[0]")
More information about the bind10-changes
mailing list