Better error reporting for bad trait definitions.
In the case someone does destination_trait: source_trait instead of destination_trait: fields: source_trait it will now get a proper error message. Change-Id: Ia22f58b6443714c2a407c7a3f94ed24f437efc1c
This commit is contained in:
parent
9fa408ce74
commit
3c0d142d0f
@ -105,7 +105,13 @@ class TraitDefinition(object):
|
|||||||
self.cfg = trait_cfg
|
self.cfg = trait_cfg
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
type_name = trait_cfg.get('type', 'text')
|
type_name = None
|
||||||
|
try:
|
||||||
|
type_name = trait_cfg.get('type', 'text')
|
||||||
|
except AttributeError as e:
|
||||||
|
raise EventDefinitionException(
|
||||||
|
"Unable to get type for '%s'" % trait_cfg,
|
||||||
|
self.cfg)
|
||||||
|
|
||||||
if 'plugin' in trait_cfg:
|
if 'plugin' in trait_cfg:
|
||||||
plugin_cfg = trait_cfg['plugin']
|
plugin_cfg = trait_cfg['plugin']
|
||||||
|
@ -143,6 +143,13 @@ class TestTraitDefinition(DistillerTestBase):
|
|||||||
self.fake_plugin_map = dict(test=self.test_plugin_class,
|
self.fake_plugin_map = dict(test=self.test_plugin_class,
|
||||||
nothing=self.nothing_plugin_class)
|
nothing=self.nothing_plugin_class)
|
||||||
|
|
||||||
|
def test_bad_field_definition(self):
|
||||||
|
self.assertRaises(distiller.EventDefinitionException,
|
||||||
|
distiller.TraitDefinition,
|
||||||
|
'test_trait',
|
||||||
|
"foo",
|
||||||
|
self.fake_plugin_map)
|
||||||
|
|
||||||
def test_to_trait_with_plugin(self):
|
def test_to_trait_with_plugin(self):
|
||||||
cfg = dict(type='text',
|
cfg = dict(type='text',
|
||||||
fields=['payload.instance_id', 'payload.instance_uuid'],
|
fields=['payload.instance_id', 'payload.instance_uuid'],
|
||||||
|
Loading…
Reference in New Issue
Block a user