def test_clean_workspace_valid_dir(self, mock_os, mock_shutil, mock_logger): """ rapid-unit: Rapid Client:Remote Execution:Code will execute in sandboxed workspace :return: :rtype: """ executor = Executor(WorkRequest({'args': "testing arguments"}), "bogus", workspace="boggus", logger=mock_logger) mock_os.sep = '/' executor.clean_workspace() mock_shutil.rmtree.assert_called_with("boggus", ignore_errors=True)
def test_clean_workspace_invalid_dir(self, mock_os): """ rapid-unit: Rapid Client:Remote Execution:Code will execute in sandboxed workspace :return: :rtype: """ executor = Executor(WorkRequest({'args': "testing arguments"}), "bogus", workspace="boggus") mock_os.path.isdir.return_value = False mock_os.sep = '/' executor.clean_workspace() mock_os.makedirs.assert_called_with("boggus")
def test_clean_workspace_valid_dir_exception(self, mock_os, mock_shutil, mock_logger): """ rapid-unit: Rapid Client:Remote Execution:Code will execute in sandboxed workspace :return: :rtype: """ executor = Executor(WorkRequest({'args': "testing arguments"}), "bogus", workspace="boggus", logger=mock_logger) def throw_exception(*args, **kwargs): raise Exception("Should not see this") mock_os.sep = '/' mock_shutil.rmtree = throw_exception executor.clean_workspace()
def test_clean_workspace_invalid_dir_exception(self, mock_os): """ rapid-unit: Rapid Client:Remote Execution:Code will execute in sandboxed workspace :return: :rtype: """ executor = Executor(WorkRequest({'args': "testing arguments"}), "bogus", workspace="boggus") mock_logger = Mock() executor.logger = mock_logger self_exception = Exception("Should not see this") def throw_exception(*args, **kwargs): raise self_exception mock_os.makedirs = throw_exception mock_os.path.isdir.return_value = False mock_os.sep = '/' executor.clean_workspace() mock_logger.exception.assert_called_with(self_exception)