def test_validate_add_causal_relationship_action_wrong_tgt_category(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_add_causal_relationship_action('123', 'a1') # Test action result = AddCausalRelationshipValidator.validate(action, idx) # Test assertion self._assert_fault_result(result, 132)
def test_validate_execute_mistral_action_with_none_workflow(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_execute_mistral_action(None, 'host_2', 'down') # Test action result = ExecuteMistralValidator.validate(action, idx) # Test assertions self._assert_fault_result(result, 133)
def _validate_execute_mistral_action_with_empty_workflow(self, validator): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_execute_mistral_action('', 'host_2', 'down') # Test action result = validator.validate(action, idx) # Test assertions self._assert_fault_result(result, 133)
def test_validate_execute_mistral_action_with_func(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = \ self._create_v1_execute_mistral_action( 'wf_1', 'host_2', 'down', func1='get_attr(alarm, name)') # Test action result = self.validator.validate(action, idx) # Test assertions self._assert_fault_result(result, 137)
def test_validate_add_causal_relationship_action_without_source(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_add_causal_relationship_action('a1', 'a2') action[TemplateFields.ACTION_TARGET].pop(TemplateFields.SOURCE, None) # Test action result = AddCausalRelationshipValidator.validate(action, idx) # Test assertion self._assert_fault_result(result, 130)
def test_validate_raise_alarm_action_without_alarm_name(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_raise_alarm_action('abc') action[TemplateFields.PROPERTIES].pop(TemplateFields.ALARM_NAME) # Test action result = RaiseAlarmValidator.validate(action, idx) # Test assertions self._assert_fault_result(result, 125)
def test_validate_execute_mistral_action_without_workflow(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_execute_mistral_action('wf_1', 'host_2', 'down') action[TemplateFields.PROPERTIES].pop(WORKFLOW) # Test action result = ExecuteMistralValidator.validate(action, idx) # Test assertions self._assert_fault_result(result, 133)
def test_validate_set_state_action_without_state_property(self): # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_set_state_action('123') action[TemplateFields.PROPERTIES].pop(TemplateFields.STATE, None) # Test action result = SetStateValidator.validate(action, idx) # Test assertions self._assert_fault_result(result, 128)
def _validate_execute_mistral_action_without_additional_props( self, validator): # Test setup - having only the 'workflow' param is a legal config idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_no_input_mistral_action('wf_1') # Test action result = validator.validate(action, idx) # Test assertions self._assert_correct_result(result)
def test_validate_execute_mistral_action_with_input_prop(self): """A version1 execute_mistral action can have an 'input' property""" # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_execute_mistral_action('wf_1', 'host_2', 'down') action[TemplateFields.PROPERTIES]['input'] = 'kuku' # Test action result = self.validator.validate(action, idx) # Test assertions self._assert_correct_result(result)
def test_validate_execute_mistral_action_without_additional_params(self): # Test setup - having only the 'workflow' param is a legal config idx = DEFINITIONS_INDEX_MOCK.copy() action = self._create_execute_mistral_action('wf_1', 'host_2', 'down') action[TemplateFields.PROPERTIES].pop('host') action[TemplateFields.PROPERTIES].pop('host_state') # Test action result = ExecuteMistralValidator.validate(action, idx) # Test assertions self._assert_correct_result(result)
def test_v2_validate_old_execute_mistral_action(self): """Test version2 validator on version1 template. An execute_mistral action from version 1 should fail in the validation of version 2. """ # Test setup idx = DEFINITIONS_INDEX_MOCK.copy() v1_action = \ self._create_v1_execute_mistral_action('wf_1', 'host_2', 'down') # Test action result = self.validator.validate(v1_action, idx) # Test assertions self._assert_fault_result(result, 136)