From 0997552722dc4845a854e0e6f8d7f18058e26380 Mon Sep 17 00:00:00 2001 From: shangxdy Date: Fri, 8 Jul 2016 15:15:00 +0800 Subject: Synchronise the openstack bugs When run unittests through tox, some test cases are always error, the errors are already done in openstack community, so it's necessary to synchronise the fixes. Change-Id: Ib29078e6cc138a474e89c6a2cc90ad7a1db1bb46 JIRA: PARSER-63 Signed-off-by: shangxdy --- tosca2heat/tosca-parser/toscaparser/parameters.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tosca2heat/tosca-parser/toscaparser/parameters.py') diff --git a/tosca2heat/tosca-parser/toscaparser/parameters.py b/tosca2heat/tosca-parser/toscaparser/parameters.py index 983aee3..1d2cb29 100644 --- a/tosca2heat/tosca-parser/toscaparser/parameters.py +++ b/tosca2heat/tosca-parser/toscaparser/parameters.py @@ -27,8 +27,9 @@ log = logging.getLogger('tosca') class Input(object): - INPUTFIELD = (TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS) = \ - ('type', 'description', 'default', 'constraints') + INPUTFIELD = (TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS, REQUIRED, + STATUS) = ('type', 'description', 'default', + 'constraints', 'required', 'status') def __init__(self, name, schema_dict): self.name = name @@ -53,7 +54,7 @@ class Input(object): def validate(self, value=None): self._validate_field() self.validate_type(self.type) - if value: + if value is not None: self._validate_value(value) def _validate_field(self): @@ -68,13 +69,16 @@ class Input(object): ExceptionCollector.appendException( ValueError(_('Invalid type "%s".') % type)) + # TODO(anyone) Need to test for any built-in datatype not just network + # that is, tosca.datatypes.* and not assume tosca.datatypes.network.* + # TODO(anyone) Add support for tosca.datatypes.Credential def _validate_value(self, value): tosca = EntityType.TOSCA_DEF datatype = None if self.type in tosca: datatype = tosca[self.type] - elif EntityType.DATATYPE_PREFIX + self.type in tosca: - datatype = tosca[EntityType.DATATYPE_PREFIX + self.type] + elif EntityType.DATATYPE_NETWORK_PREFIX + self.type in tosca: + datatype = tosca[EntityType.DATATYPE_NETWORK_PREFIX + self.type] DataEntity.validate_datatype(self.type, value, None, datatype) -- cgit 1.2.3-korg