示例#1
0
    def test_list_with_dependency_when_matches(self):
        parameters = []
        values = ObservableDict()
        dep_param = create_parameter_model('dep_param')
        parameter = create_parameter_model('param',
                                           type='list',
                                           values_script="echo '${dep_param}_\n' '_${dep_param}_'",
                                           all_parameters=parameters,
                                           other_param_values=values)
        parameters.extend([dep_param, parameter])

        values['dep_param'] = 'abc'
        error = parameter.validate_value(' _abc_')
        self.assertIsNone(error)
    def __init__(self,
                 config_object,
                 path,
                 username,
                 audit_name,
                 pty_enabled_default=True,
                 ansi_enabled_default=True,
                 parameter_values=None):
        super().__init__()

        short_config = read_short(path, config_object)
        self.name = short_config.name
        self._ansi_enabled_default = ansi_enabled_default
        self._pty_enabled_default = pty_enabled_default
        self._config_folder = os.path.dirname(path)

        self._username = username
        self._audit_name = audit_name
        self.schedulable = False

        self.parameters = ObservableList()
        self.parameter_values = ObservableDict()

        self._original_config = config_object
        self._included_config_path = _TemplateProperty(
            config_object.get('include'),
            parameters=self.parameters,
            values=self.parameter_values)
        self._included_config_prop.bind(self._included_config_path,
                                        self._path_to_json)

        self._reload_config()

        self.parameters.subscribe(self)

        self._init_parameters(username, audit_name)

        if parameter_values is not None:
            self.set_all_param_values(parameter_values)
        else:
            for parameter in self.parameters:
                self.parameter_values[parameter.name] = parameter.default

        self._reload_parameters({})

        self._included_config_prop.subscribe(
            lambda old, new: self._reload(old))
示例#3
0
    def setUp(self):
        super().setUp()

        self.parameters = ObservableList()
        self.values = ObservableDict()