diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-09-12 15:20:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-09-12 15:20:00 +0000 |
commit | 8df7697cc85f97d825e7e7ff5ea7146f91b5a7c9 (patch) | |
tree | 8506a69747e40ce1346a52e85a75e19bf9a61873 /tosca2heat/tosca-parser/toscaparser/substitution_mappings.py | |
parent | f59d4d244d9127e56dbc80c48c08f70514a10546 (diff) | |
parent | 44540b6c2b16637659099c65e31309fc7573ba7d (diff) |
Merge "Add keys validation testcase in substitution_mapping class"
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/substitution_mappings.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/substitution_mappings.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py b/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py index fe47ae4..35ffdf3 100644 --- a/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py +++ b/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py @@ -19,7 +19,7 @@ from toscaparser.common.exception import MissingRequiredInputError from toscaparser.common.exception import MissingRequiredParameterError from toscaparser.common.exception import UnknownFieldError from toscaparser.elements.nodetype import NodeType - +from toscaparser.utils.gettextutils import _ log = logging.getLogger('tosca') @@ -47,6 +47,11 @@ class SubstitutionMappings(object): self._capabilities = None self._requirements = None + @property + def type(self): + if self.sub_mapping_def: + return self.sub_mapping_def.get(self.NODE_TYPE) + @classmethod def get_node_type(cls, sub_mapping_def): if isinstance(sub_mapping_def, dict): @@ -84,7 +89,7 @@ class SubstitutionMappings(object): for key in self.sub_mapping_def.keys(): if key not in self.SECTIONS: ExceptionCollector.appendException( - UnknownFieldError(what='SubstitutionMappings', + UnknownFieldError(what=_('SubstitutionMappings'), field=key)) def _validate_type(self): @@ -119,7 +124,7 @@ class SubstitutionMappings(object): propery.name not in [input.name for input in self.inputs]: ExceptionCollector.appendException( MissingRequiredInputError( - what='SubstitutionMappings with node_type:' + what=_('SubstitutionMappings with node_type:') + self.node_type, input_name=propery.name)) @@ -140,7 +145,7 @@ class SubstitutionMappings(object): if input.name not in property_names and input.default is None: ExceptionCollector.appendException( MissingRequiredParameterError( - what='SubstitutionMappings with node_type:' + what=_('SubstitutionMappings with node_type:') + self.node_type, input_name=input.name)) |