def test_check_only_installed(self, mock_is_installed_happy): test_check_command = "test check" installation = actions.Installation(test_check_command, "1") try: installation.execute() except BaseException: pytest.fail()
def test_successful_install(self, mock_is_installed_not_installed, mock_subprocess_run_happy): test_check_command = "test check" test_install_command = "test install" installation = actions.Installation(test_check_command, "1", test_install_command) try: installation.execute() except BaseException: pytest.fail()
def test_check_only_not_installed__log_and_raise( self, mock_log_and_raise, mock_is_installed_not_installed, ): test_check_command = "test check" installation = actions.Installation(test_check_command, "1") with pytest.raises(actions.ActionFailureException): installation.execute() call_args = mock_log_and_raise.call_args[0] assert errors.AC_CHECK_ONLY_INSTALLATION_NOT_INSTALLED in call_args
def test_failed_install__log_and_raise( self, mock_is_installed_not_installed, mock_log_and_raise, mock_subprocess_run_failed, ): test_check_command = "test check" test_install_command = "test install" installation = actions.Installation(test_check_command, "1", test_install_command) with pytest.raises(actions.ActionFailureException): installation.execute() call_args = mock_log_and_raise.call_args[0] assert errors.AC_FAILED_TO_INSTALL in call_args
def parse_installation( file_sync_config: Dict[str, Union[str, bool, int]], exec_context: Optional[ExecutionContext] = None, ) -> actions.Installation: """Creates an Installation object from configuration.""" if any(x not in file_sync_config for x in REQUIRED_INSTALLATION_NODES): missing_nodes = filter( lambda x: x not in file_sync_config, [node for node in REQUIRED_INSTALLATION_NODES], ) utils.log_and_raise( logger.error, f"File sync config missing nodes {','.join(missing_nodes)}", ValueError, errors.NP_MISSING_FILE_SYNC_CONFIG, ) return actions.Installation( install_command=file_sync_config.get(const.INSTALL_COMMAND, None), check_command=file_sync_config[const.CHECK_COMMAND], key=file_sync_config[const.NODE_KEY], dependency_keys=file_sync_config.get(const.DEPENDENCY, None))