Exemplo n.º 1
0
    def test_cleanup_call_no_repo(self, remote_cls, installation_cls, transaction_cls, rmtree):
        """Test the cleanup call with no repository created."""
        flatpak = FlatpakManager("any path")

        self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls)

        file_mock_path = Mock()
        file_mock_path.get_path.return_value = "/install/test/path"
        self._installation.get_path.return_value = file_mock_path

        flatpak.initialize_with_path("/install/test/path")
        flatpak.cleanup()

        rmtree.assert_not_called()
Exemplo n.º 2
0
    def run(self):
        """Find the size of flatpaks to install.

        :return: the required size
        :rtype: Size
        """
        flatpak_payload = FlatpakManager(self._sysroot)

        # Initialize temporal repo to enable reading of the remote
        flatpak_payload.initialize_with_path("/var/tmp/anaconda-flatpak-temp")

        required_size = Size(flatpak_payload.get_required_size())
        # Clean up temporal repo again
        flatpak_payload.cleanup()

        return required_size
Exemplo n.º 3
0
    def test_initialize_with_path(self, remote_cls, installation_cls, transaction_cls):
        """Test flatpak initialize with path."""
        self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls)

        flatpak = FlatpakManager("/mock/system/root/path")
        flatpak.initialize_with_path("/test/path/installation")

        remote_cls.new.assert_called_once()
        installation_cls.new_for_path.assert_called_once()
        transaction_cls.new_for_installation.assert_called_once_with(self._installation)

        expected_remote_calls = [call.set_gpg_verify(False),
                                 call.set_url(flatpak.LOCAL_REMOTE_PATH)]
        self.assertEqual(self._remote.method_calls, expected_remote_calls)

        expected_remote_calls = [call.add_remote(self._remote, False, None)]
        self.assertEqual(self._installation.method_calls, expected_remote_calls)
Exemplo n.º 4
0
    def test_cleanup_call_mock_repo(self, remote_cls, installation_cls, transaction_cls, rmtree):
        """Test the cleanup call with mocked repository."""
        flatpak = FlatpakManager("any path")

        self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls)

        with TemporaryDirectory() as temp:
            install_path = os.path.join(temp, "install/test/path")
            file_mock_path = Mock()
            file_mock_path.get_path.return_value = install_path
            self._installation.get_path.return_value = file_mock_path

            os.makedirs(install_path)

            flatpak.initialize_with_path(install_path)
            flatpak.cleanup()

            rmtree.assert_called_once_with(install_path)