def run_test(self): """Run the InstallPackagesTask class.""" callback = Mock() dnf_manager = Mock() dnf_manager.install_packages.side_effect = self._install_packages task = InstallPackagesTask(dnf_manager) task.progress_changed_signal.connect(callback) task.run() self.assertEqual(task.name, "Install packages") dnf_manager.install_packages.assert_called_once_with( task.report_progress) callback.assert_has_calls([ call(0, "Preparing transaction from installation source"), call(0, "Installing p1"), call(0, "Installing p2"), call(0, "Installing p3"), ])
def install(self): progress_message(N_('Starting package installation process')) # Get the packages configuration and selection data. configuration = self.get_packages_configuration() selection = self.get_packages_selection() # Add the rpm macros to the global transaction environment task = SetRPMMacrosTask(configuration) task.run() try: # Resolve packages. task = ResolvePackagesTask(self._dnf_manager, selection) task.run() except NonCriticalInstallationError as e: # FIXME: This is a temporary workaround. # Allow users to handle the error. If they don't want # to continue with the installation, raise a different # exception to make sure that we will not run the error # handler again. if error_handler.cb(e) == ERROR_RAISE: raise InstallationError(str(e)) from e # Set up the download location. task = PrepareDownloadLocationTask(self._dnf_manager) task.run() # Download the packages. task = DownloadPackagesTask(self._dnf_manager) task.progress_changed_signal.connect(self._progress_cb) task.run() # Install the packages. task = InstallPackagesTask(self._dnf_manager) task.progress_changed_signal.connect(self._progress_cb) task.run() # Clean up the download location. task = CleanUpDownloadLocationTask(self._dnf_manager) task.run()