def _inputs(self): inputs = [] for name, attrs in self._tpl_inputs().items(): input = Input(name, attrs) if self.parsed_params and name in self.parsed_params: input.validate(self.parsed_params[name]) inputs.append(input) return inputs
def test_built_in_nested_datatype_portdef(self): tpl_snippet = ''' inputs: db_port: type: PortDef description: Port for the MySQL database ''' inputs = yamlparser.simple_parse(tpl_snippet)['inputs'] name, attrs = list(inputs.items())[0] input = Input(name, attrs) self.assertIsNone(input.validate(3360)) try: input.validate(336000) except Exception as err: self.assertTrue(isinstance(err, exception.ValidationError)) self.assertEqual('None: 336000 is out of range (min:1, ' 'max:65535).', err.__str__())
def test_inputs(self): tpl_snippet = ''' inputs: cpus: type: integer description: Number of CPUs for the server. constraint: - valid_values: [ 1, 2, 4, 8 ] ''' inputs = (parser.utils.yamlparser. simple_parse(tpl_snippet)['inputs']) name, attrs = list(inputs.items())[0] input = Input(name, attrs) try: input.validate() except Exception as err: self.assertTrue(isinstance(err, exception.UnknownFieldError)) self.assertEqual('Input cpus contain(s) unknown field: ' '"constraint", refer to the definition to ' 'verify valid values.', err.__str__())