def test_replace_remote(self, remote_cls, installation_cls, transaction_cls, open_mock, variant_type, variant): """Test flatpak replace remote for installed refs call.""" flatpak = FlatpakManager("/system/test-root") self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls) install_path_mock = Mock() install_path_mock.get_path.return_value = "/path" self._installation.get_path.return_value = install_path_mock self._installation.list_installed_refs.return_value = [ RefMock("app/org.test/x86_64/stable"), RefMock("runtime/org.run/x86_64/stable"), ] flatpak.initialize_with_system_path() flatpak.replace_installed_refs_remote("cylon_officer") # test that every file is read and written open_mock.has_calls([ call("/path/app/org.test/x86_64/stable/active/deploy", "rb"), call("/path/app/org.test/x86_64/stable/active/deploy", "wb"), call("/path/runtime/org.run/x86_64/stable/active/deploy", "rb"), call("/path/runtime/org.run/x86_64/stable/active/deploy", "wb"), ])
def run(self): self.report_progress(_("Starting Flatpak installation")) flatpak_manager = FlatpakManager(self._sysroot) # Initialize new repo on the installed system flatpak_manager.initialize_with_system_path() flatpak_manager.install_all() self.report_progress(_("Post-installation flatpak tasks")) flatpak_manager.add_remote("fedora", "oci+https://registry.fedoraproject.org") flatpak_manager.replace_installed_refs_remote("fedora") flatpak_manager.remove_remote(FlatpakManager.LOCAL_REMOTE_NAME) self.report_progress(_("Flatpak installation has finished"))
def test_replace_remote(self, remote_cls, installation_cls, transaction_cls, open_mock, variant_type, variant): """Test flatpak replace remote for installed refs call.""" flatpak = FlatpakManager("/system/test-root") self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls) install_path = "/installation/path" install_path_mock = Mock() install_path_mock.get_path.return_value = install_path self._installation.get_path.return_value = install_path_mock ref_mock_list = [ RefMock(name="org.space.coolapp", kind=RefKind.APP, arch="x86_64", branch="stable"), RefMock(name="org.space.coolruntime", kind=RefKind.RUNTIME, arch="x86_64", branch="stable") ] self._installation.list_installed_refs.return_value = ref_mock_list flatpak.initialize_with_system_path() flatpak.replace_installed_refs_remote("cylon_officer") expected_refs = list(map(lambda x: x.format_ref(), ref_mock_list)) open_calls = [] for ref in expected_refs: ref_file_path = os.path.join(install_path, ref, "active/deploy") open_calls.append(call(ref_file_path, "rb")) open_calls.append(call(ref_file_path, "wb")) # test that every file is read and written assert open_mock.call_count == 2 * len(expected_refs) open_mock.has_calls(open_calls)
def run(self): self.report_progress(_("Starting Flatpak installation")) flatpak_manager = FlatpakManager(self._sysroot) # Initialize new repo on the installed system flatpak_manager.initialize_with_system_path() try: flatpak_manager.install_all() except FlatpakInstallError as e: raise PayloadInstallError( "Failed to install flatpaks: {}".format(e)) from e self.report_progress(_("Post-installation flatpak tasks")) flatpak_manager.add_remote("fedora", "oci+https://registry.fedoraproject.org") flatpak_manager.replace_installed_refs_remote("fedora") flatpak_manager.remove_remote(FlatpakManager.LOCAL_REMOTE_NAME) self.report_progress(_("Flatpak installation has finished"))