summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJelte Jansen <jelte@isc.org>2010-12-07 15:52:45 +0100
committerJelte Jansen <jelte@isc.org>2010-12-07 15:52:45 +0100
commita5ef1c8e062f45c42d65c91f91ef32dbeabe761c (patch)
tree6879686fd2f507ae3f92ccffad7e4a9804df1651 /src
parentcreate branch for ticket #202 (diff)
downloadkea-a5ef1c8e062f45c42d65c91f91ef32dbeabe761c.tar.xz
kea-a5ef1c8e062f45c42d65c91f91ef32dbeabe761c.zip
return an error in bindctl on 'config set' for an item not described in the .spec file
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac202@3757 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src')
-rw-r--r--src/lib/python/isc/config/config_data.py15
-rw-r--r--src/lib/python/isc/config/tests/config_data_test.py11
2 files changed, 15 insertions, 11 deletions
diff --git a/src/lib/python/isc/config/config_data.py b/src/lib/python/isc/config/config_data.py
index 66ba92ec1f..1e3afd145d 100644
--- a/src/lib/python/isc/config/config_data.py
+++ b/src/lib/python/isc/config/config_data.py
@@ -464,12 +464,15 @@ class MultiConfigData:
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
diff --git a/src/lib/python/isc/config/tests/config_data_test.py b/src/lib/python/isc/config/tests/config_data_test.py
index 90c2212081..b61a259854 100644
--- a/src/lib/python/isc/config/tests/config_data_test.py
+++ b/src/lib/python/isc/config/tests/config_data_test.py
@@ -335,6 +335,8 @@ class TestMultiConfigData(unittest.TestCase):
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 @@ class TestMultiConfigData(unittest.TestCase):
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.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.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]")