def test_install(self, remote_cls, installation_cls, transaction_cls):
        """Test flatpak installation is working."""
        progress = Mock()
        flatpak = FlatpakManager(sysroot="remote/path", callback=progress)

        self._setup_flatpak_objects(remote_cls, installation_cls,
                                    transaction_cls)
        flatpak.initialize_with_system_path()

        self._installation.list_remote_refs_sync.return_value = [
            RefMock("app/org.space.coolapp/x86_64/stable"),
            RefMock("app/com.prop.notcoolapp/i386/f36"),
            RefMock("runtime/org.space.coolruntime/x86_64/stable"),
            RefMock("runtime/com.prop.notcoolruntime/i386/f36"),
        ]

        flatpak.install_all()
        assert self._transaction.mock_calls == [
            call.connect("new_operation", flatpak._operation_started_callback),
            call.connect("operation_done",
                         flatpak._operation_stopped_callback),
            call.connect("operation_error", flatpak._operation_error_callback),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             "app/org.space.coolapp/x86_64/stable", None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             "app/com.prop.notcoolapp/i386/f36", None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             "runtime/org.space.coolruntime/x86_64/stable",
                             None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             "runtime/com.prop.notcoolruntime/i386/f36", None),
            call.run()
        ]

        assert progress.mock_calls == []
Exemple #2
0
    def test_install(self, remote_cls, installation_cls, transaction_cls):
        """Test flatpak installation is working."""
        flatpak = FlatpakManager("remote/path")

        self._setup_flatpak_objects(remote_cls, installation_cls,
                                    transaction_cls)

        flatpak.initialize_with_system_path()

        mock_ref_list = [
            RefMock(name="org.space.coolapp",
                    kind=RefKind.APP,
                    arch="x86_64",
                    branch="stable"),
            RefMock(name="com.prop.notcoolapp",
                    kind=RefKind.APP,
                    arch="i386",
                    branch="f36"),
            RefMock(name="org.space.coolruntime",
                    kind=RefKind.RUNTIME,
                    arch="x86_64",
                    branch="stable"),
            RefMock(name="com.prop.notcoolruntime",
                    kind=RefKind.RUNTIME,
                    arch="i386",
                    branch="f36")
        ]

        self._installation.list_remote_refs_sync.return_value = mock_ref_list

        flatpak.install_all()

        expected_calls = [
            call.connect("new_operation", flatpak._operation_started_callback),
            call.connect("operation_done",
                         flatpak._operation_stopped_callback),
            call.connect("operation_error", flatpak._operation_error_callback),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             mock_ref_list[0].format_ref(), None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             mock_ref_list[1].format_ref(), None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             mock_ref_list[2].format_ref(), None),
            call.add_install(FlatpakManager.LOCAL_REMOTE_NAME,
                             mock_ref_list[3].format_ref(), None),
            call.run()
        ]

        assert self._transaction.mock_calls == expected_calls