# for type any, we determine the 'type' by what value is set
# (which would be either list or dict)
cur_value, _ = self.get_value(identifier)
- type_any = module_spec['item_type'] == 'any'
+ type_any = isc.config.config_data.spec_part_is_any(module_spec)
# the specified element must be a list or a named_set
if 'list_item_spec' in module_spec or\
self._add_value_to_named_set(identifier, item_name,
item_value)
else:
- raise isc.cc.data.DataNotFoundError(str(identifier) + " is not a list or a named set")
+ raise isc.cc.data.DataTypeError(str(identifier) + " is not a list or a named set")
def _remove_value_from_list(self, identifier, value):
if value is None:
(type_any and type(cur_value) == dict):
self._remove_value_from_named_set(identifier, value_str)
else:
- raise isc.cc.data.DataNotFoundError(str(identifier) + " is not a list or a named_set")
+ raise isc.cc.data.DataTypeError(str(identifier) + " is not a list or a named_set")
self.assertRaises(isc.cc.data.DataNotFoundError, uccs.add_value, 1, "a")
self.assertRaises(isc.cc.data.DataNotFoundError, uccs.add_value, "no_such_item", "a")
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.add_value, "Spec2/item1", "a")
self.assertRaises(isc.cc.data.DataNotFoundError, uccs.remove_value, 1, "a")
self.assertRaises(isc.cc.data.DataNotFoundError, uccs.remove_value, "no_such_item", "a")
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.remove_value, "Spec2/item1", "a")
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.remove_value, "Spec2", "")
+ # add and remove should raise DataNotFoundError when used with items
+ # that are not a list or named_set (more importantly, they should
+ # not raise TypeError)
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.add_value, "Spec2/item1", "a")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.remove_value, "Spec2/item1", "a")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.add_value, "Spec2", "")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.remove_value, "Spec2", "")
self.assertEqual({}, uccs._local_changes)
uccs.add_value("Spec2/item5", "foo")
items_as_str = [ '1234', 'foo', 'true', 'false' ]
def test_fails():
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.add_value, "Spec40/item1", "foo")
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.add_value, "Spec40/item1", "foo", "bar")
- self.assertRaises(isc.cc.data.DataNotFoundError, uccs.remove_value, "Spec40/item1", "foo")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.add_value, "Spec40/item1", "foo")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.add_value, "Spec40/item1", "foo", "bar")
+ self.assertRaises(isc.cc.data.DataTypeError, uccs.remove_value, "Spec40/item1", "foo")
self.assertRaises(isc.cc.data.DataTypeError, uccs.remove_value, "Spec40/item1[0]", None)
# A few helper functions to perform a number of tests