Bugfix the error in DataEntity.validate_datatype with functions

Change-Id: I42a369cccfb890ccdb8d49e01a220752cd710b4d
Related-Bug: 1583022
This commit is contained in:
Miguel Caballer 2016-05-18 10:29:01 +02:00
parent 8dd70b1df8
commit 2cfb765146
2 changed files with 14 additions and 0 deletions

View File

@ -122,6 +122,9 @@ class DataEntity(object):
If type is list or map, validate its entry by entry_schema(if defined)
If type is a user-defined complex datatype, custom_def is required.
'''
from toscaparser.functions import is_function
if is_function(value):
return value
if type == Schema.STRING:
return validateutils.validate_string(value)
elif type == Schema.INTEGER:

View File

@ -504,3 +504,14 @@ class DataTypeTest(TestCase):
'value of type "tosca.datatypes.Credential" contains'
' unknown field "some_field". Refer to the definition'
' to verify valid values'), err.__str__())
def test_functions_datatype(self):
value_snippet = '''
admin_credential:
user: username
token: { get_input: password }
'''
value = yamlparser.simple_parse(value_snippet)
data = DataEntity('tosca.datatypes.Credential',
value.get('admin_credential'))
self.assertIsNotNone(data.validate())