Fix validation for invalid type
Fix validation for invalid type when found along with an imports section in a TOSCA template. Change-Id: I6b0c6299c1ef96b037527db68f9f86a5a81dded5 Closes-Bug: #1656994
This commit is contained in:
parent
64afa7f2f6
commit
d3498b3652
|
@ -93,7 +93,7 @@ class EntityType(object):
|
|||
return False
|
||||
|
||||
def entity_value(self, defs, key):
|
||||
if key in defs:
|
||||
if defs and key in defs:
|
||||
return defs[key]
|
||||
|
||||
def get_value(self, ndtype, defs=None, parent=None):
|
||||
|
@ -102,7 +102,7 @@ class EntityType(object):
|
|||
if not hasattr(self, 'defs'):
|
||||
return None
|
||||
defs = self.defs
|
||||
if ndtype in defs:
|
||||
if defs and ndtype in defs:
|
||||
# copy the value to avoid that next operations add items in the
|
||||
# item definitions
|
||||
value = copy.copy(defs[ndtype])
|
||||
|
@ -110,7 +110,7 @@ class EntityType(object):
|
|||
p = self
|
||||
if p:
|
||||
while p:
|
||||
if ndtype in p.defs:
|
||||
if p.defs and ndtype in p.defs:
|
||||
# get the parent value
|
||||
parent_value = p.defs[ndtype]
|
||||
if value:
|
||||
|
|
|
@ -35,6 +35,9 @@ topology_template:
|
|||
default: 3306
|
||||
|
||||
node_templates:
|
||||
xyz:
|
||||
type: tosca.nodes.XYZ
|
||||
|
||||
wordpress:
|
||||
type: tosca.nodes.WebApplication.WordPress
|
||||
requirement:
|
||||
|
|
|
@ -580,6 +580,10 @@ class ToscaTemplateTest(TestCase):
|
|||
exception.ExceptionCollector.assertExceptionMessage(
|
||||
exception.MissingRequiredFieldError, err9_msg)
|
||||
|
||||
err10_msg = _('Type "tosca.nodes.XYZ" is not a valid type.')
|
||||
exception.ExceptionCollector.assertExceptionMessage(
|
||||
exception.InvalidTypeError, err10_msg)
|
||||
|
||||
def test_invalid_section_names(self):
|
||||
tosca_tpl = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
|
|
Loading…
Reference in New Issue