def test_run_failing(self, mock_run_validation, mock_cleanup_identity_file, mock_write_identity_file, mock_get_object_client, get_workflow_client_mock): mock_ctx = mock.MagicMock() mistral = mock.MagicMock() get_workflow_client_mock.return_value = mistral environment = collections.namedtuple('environment', ['variables']) mistral.environments.get.return_value = environment(variables={ 'private_key': 'shhhh' }) swiftclient = mock.MagicMock(url='http://swift:8080/v1/AUTH_test') mock_get_object_client.return_value = swiftclient mock_write_identity_file.return_value = 'identity_file_path' mock_run_validation.side_effect = ProcessExecutionError( stdout='output', stderr='error') action = validations.RunValidationAction('validation') expected = actions.Result( data=None, error={ 'stdout': 'output', 'stderr': 'error' }) self.assertEqual(expected, action.run(mock_ctx)) mock_write_identity_file.assert_called_once_with('shhhh') mock_run_validation.assert_called_once_with( mock_get_object_client(), 'validation', 'identity_file_path', constants.DEFAULT_CONTAINER_NAME, mock_ctx) mock_cleanup_identity_file.assert_called_once_with( 'identity_file_path')
def test_run(self, mock_run_validation, mock_cleanup_identity_file, mock_write_identity_file, get_workflow_client_mock): mistral = mock.MagicMock() get_workflow_client_mock.return_value = mistral environment = collections.namedtuple('environment', ['variables']) mistral.environments.get.return_value = environment( variables={'private_key': 'shhhh'}) mock_write_identity_file.return_value = 'identity_file_path' mock_run_validation.return_value = 'output', 'error' action = validations.RunValidationAction('validation') expected = mistral_workflow_utils.Result(data={ 'stdout': 'output', 'stderr': 'error' }, error=None) self.assertEqual(expected, action.run()) mock_write_identity_file.assert_called_once_with('shhhh') mock_run_validation.assert_called_once_with( 'validation', 'identity_file_path', constants.DEFAULT_CONTAINER_NAME) mock_cleanup_identity_file.assert_called_once_with( 'identity_file_path')