Bugfix the error in DataEntity.validate_datatype with functions
Change-Id: I42a369cccfb890ccdb8d49e01a220752cd710b4d Related-Bug: 1583022
This commit is contained in:
parent
8dd70b1df8
commit
2cfb765146
@ -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:
|
||||
|
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user