def __on_add_clicked(self): self.edit_index = None parent = self.details_parent or QtGui.QDialog() self.new_dlg = VariableDialog(parent) new_var = HalVar('', '') new_var.type = 'text' self.new_dlg.setModel(new_var) self.new_dlg.show() self.new_dlg.accepted.connect(self.__on_add_accepted) self.new_dlg.rejected.connect(self.__on_add_rejected)
def __on_add_clicked(self): self.edit_index = None parent = self.details_parent or QtGui.QDialog() self.new_dlg = VariableDialog(parent) new_var =HalVar('', '') new_var.type = 'text' self.new_dlg.setModel(new_var) self.new_dlg.show() self.new_dlg.accepted.connect(self.__on_add_accepted) self.new_dlg.rejected.connect(self.__on_add_rejected)
def testDictionarySet(self): self.test_var = HalVar() for k in self.var_values.keys(): msg = 'variable %s has value %s and it was set as %s '%(k, self.test_var[k], self.var_values[k]) self.assertNotEquals(self.var_values[k], self.test_var[k], msg) self.test_var.dictionary = self.var_values for k in self.var_values.keys(): msg = 'variable %s has value %s and it was set as %s '%(k, self.test_var[k], self.var_values[k]) self.assertEquals(self.var_values[k], self.test_var[k], msg)
def run(self): is_valid, errors = self.validate_args() su = self.value_substitutor.substitute if is_valid: r = filter(lambda x: x['name']==su(self.kwargs['Variable']), self.executor.bundle_vars) if r: r[0]['value'] = su(self.kwargs["NewValue"]) else: self.executor.bundle_vars.append(HalVar.from_dict({'name':su(self.kwargs['Variable']), 'value':su(self.kwargs["NewValue"])})) else: raise InvalidCommandArgumentsError(str(errors))
def __objectify__(self, cfg): obj_vars = [] obj_req_vars = [] obj_res = [] obj_req_res = [] keys_vars = {'Variables': obj_vars, 'RequiredVariables': obj_req_vars} keys_res = {'Resources': obj_res, 'RequiredResources': obj_req_res} for key in keys_vars.keys(): if key in cfg: for v in cfg[key]: keys_vars[key].append(HalVar.from_dict(v)) for key in keys_res.keys(): if key in cfg: for v in cfg[key]: keys_res[key].append(HalResource.from_dict(v)) cfg['Variables'] = obj_vars cfg['RequiredVariables'] = obj_req_vars cfg['Resources'] = obj_res cfg['RequiredResources'] = obj_req_res return cfg
def testToDictionary(self): self.test_var = HalVar.from_dict(self.var_values) self.assertEquals(len(self.var_values.keys()), len(self.test_var.dictionary.keys()))
def testIteration(self): self.test_var = HalVar.from_dict(self.var_values) d = dict( [(k, v) for k, v in self.test_var.items()]) self.assertEquals(len(d.keys()), len(self.var_values.keys()), 'Keys dont match') for k in d.keys(): self.assertTrue(self.var_values.has_key(k), 'Unknown key %s'%k)
def testIterationOfTheKeys(self): self.test_var = HalVar.from_dict(self.var_values) for k in self.test_var.keys(): msg = 'variable %s has value %s and it was set as %s '%(k, self.test_var[k], self.var_values[k]) self.assertEquals(self.var_values[k], self.test_var[k], msg)