summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
index 986d9e4..57daf7e 100644
--- a/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
+++ b/tosca2heat/tosca-parser/toscaparser/tests/test_toscatplvalidation.py
@@ -99,7 +99,7 @@ class ToscaTemplateValidationTest(TestCase):
'verify valid values.'))
def test_inputs(self):
- tpl_snippet = '''
+ tpl_snippet1 = '''
inputs:
cpus:
type: integer
@@ -109,14 +109,33 @@ class ToscaTemplateValidationTest(TestCase):
required: yes
status: supported
'''
- inputs = (toscaparser.utils.yamlparser.
- simple_parse(tpl_snippet)['inputs'])
- name, attrs = list(inputs.items())[0]
- input = Input(name, attrs)
- err = self.assertRaises(exception.UnknownFieldError, input.validate)
- self.assertEqual(_('Input "cpus" contains unknown field "constraint". '
- 'Refer to the definition to verify valid values.'),
- err.__str__())
+ tpl_snippet2 = '''
+ inputs:
+ cpus:
+ type: integer
+ description: Number of CPUs for the server.
+ constraints:
+ - valid_values: [ 1, 2, 4 ]
+ required: yes
+ status: supported
+ '''
+ inputs1 = (toscaparser.utils.yamlparser.
+ simple_parse(tpl_snippet1)['inputs'])
+ name1, attrs1 = list(inputs1.items())[0]
+ inputs2 = (toscaparser.utils.yamlparser.
+ simple_parse(tpl_snippet2)['inputs'])
+ name2, attrs2 = list(inputs2.items())[0]
+ try:
+ Input(name1, attrs1)
+ except Exception as err:
+ # err=self.assertRaises(exception.UnknownFieldError,
+ # input1.validate)
+ self.assertEqual(_('Input "cpus" contains unknown field '
+ '"constraint". Refer to the definition to '
+ 'verify valid values.'),
+ err.__str__())
+ input2 = Input(name2, attrs2)
+ self.assertTrue(input2.required)
def _imports_content_test(self, tpl_snippet, path, custom_type_def):
imports = (toscaparser.utils.yamlparser.