about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorfox <fox@fakecake.org>2026-07-05 01:51:45 +0300
committerfox <fox@fakecake.org>2026-07-05 01:51:45 +0300
commitcb436cf62a959530025b0b95e7b55aba1ac3cc99 (patch)
treee436860e9c76c532f94314639437665f49ad1824
parente55ee82912b88d4cf24d725d0e1d816c82c4f6ba (diff)
parent83a535270f1eb486cdce82a4f9062b49977e8426 (diff)
downloadfungus-launcher-cb436cf62a959530025b0b95e7b55aba1ac3cc99.tar.gz
fungus-launcher-cb436cf62a959530025b0b95e7b55aba1ac3cc99.tar.xz
Merge branch 'dev' into 'master'
Dev

See merge request git/fungus-launcher!42
-rw-r--r--fungus/umu_manager.py3
-rw-r--r--fungus/utils_pure.py40
-rw-r--r--tests/test_proton_manager.py768
-rw-r--r--tests/test_umu_manager.py881
-rw-r--r--tests/test_utils_pure.py396
5 files changed, 2079 insertions, 9 deletions
diff --git a/fungus/umu_manager.py b/fungus/umu_manager.py
index 46feccc..8d77796 100644
--- a/fungus/umu_manager.py
+++ b/fungus/umu_manager.py
@@ -77,9 +77,6 @@ def proton_to_steamrt_variant(proton_dir: str | None) -> str:
     if int(version) >= 11:
         return "steamrt4"
     return "steamrt3"
-    """Return the path to the umu-run binary."""
-    from fungus.constants import umu_run
-    return str(umu_run)
 
 
 def get_latest_umu_version() -> str | None:
diff --git a/fungus/utils_pure.py b/fungus/utils_pure.py
index 88c156e..cde9be4 100644
--- a/fungus/utils_pure.py
+++ b/fungus/utils_pure.py
@@ -21,13 +21,23 @@ def format_title(title):
     return re.sub(r"\s+", "-", title)
 
 
-def is_valid_prefix_path(path: str) -> bool:
+def is_valid_prefix_path(path: str, prefixes_dir: str | None = None) -> bool:
     """Check whether *path* lies within the configured prefixes directory.
 
     Returns ``True`` only if the resolved path is the prefixes directory
     itself or a descendant of it.
+
+    Parameters
+    ----------
+    path : str
+        The path to check.
+    prefixes_dir : str, optional
+        The prefixes directory to check against.  Defaults to the value
+        from ``fungus.constants``.
     """
-    from fungus.constants import prefixes_dir
+    if prefixes_dir is None:
+        from fungus.constants import prefixes_dir as _pd
+        prefixes_dir = _pd
 
     expanded = os.path.expanduser(path)
     resolved = os.path.realpath(expanded)
@@ -36,22 +46,40 @@ def is_valid_prefix_path(path: str) -> bool:
     return resolved == safe_root or resolved.startswith(safe_root + os.sep)
 
 
-def is_safe_prefix_path(path: str) -> bool:
+def is_safe_prefix_path(
+    path: str,
+    user_data: str | None = None,
+    user_config: str | None = None,
+) -> bool:
     """Check whether *path* is a safe target for recursive deletion.
 
     Returns ``True`` only if the resolved path lies within the fungus
     user-data or user-config directories (``~/.local/share/fungus-launcher``
     or ``~/.config/fungus-launcher``), or is one of those directories
     itself.
+
+    Parameters
+    ----------
+    path : str
+        The path to check.
+    user_data : str, optional
+        The user-data directory.  Defaults to ``PathManager.user_data()``.
+    user_config : str, optional
+        The user-config directory.  Defaults to ``PathManager.user_config()``.
     """
-    from fungus.path_manager import PathManager
+    if user_data is None:
+        from fungus.path_manager import PathManager
+        user_data = PathManager.user_data()
+    if user_config is None:
+        from fungus.path_manager import PathManager
+        user_config = PathManager.user_config()
 
     expanded = os.path.expanduser(path)
     resolved = os.path.realpath(expanded)
 
     safe_roots = [
-        os.path.realpath(PathManager.user_data()),
-        os.path.realpath(PathManager.user_config()),
+        os.path.realpath(user_data),
+        os.path.realpath(user_config),
     ]
 
     for root in safe_roots:
diff --git a/tests/test_proton_manager.py b/tests/test_proton_manager.py
new file mode 100644
index 0000000..773d595
--- /dev/null
+++ b/tests/test_proton_manager.py
@@ -0,0 +1,768 @@
+"""Tests for fungus.proton_manager — pure logic helpers.
+
+Covers:
+  - _cache_key
+  - get_arch_asset
+  - get_cache_dir
+  - clear_cache
+  - get_installed_path
+  - remove_path
+  - fetch_releases (via mocked requests.get)
+  - _fetch_with_cache (via mocked requests.get + tmp cache)
+"""
+
+import json
+from unittest.mock import MagicMock, patch
+
+import pytest
+
+
+# ---------------------------------------------------------------------------
+# Fixtures
+# ---------------------------------------------------------------------------
+
+
+@pytest.fixture()
+def mock_user_config(tmp_path):
+    """Patch PathManager.user_config to return a controlled path.
+
+    Returns the patched config directory path.
+    """
+    from fungus import path_manager as pm
+
+    config_dir = tmp_path / "test_config"
+    config_dir.mkdir()
+
+    original = pm.PathManager.user_config
+    pm.PathManager.user_config = staticmethod(lambda *a: str(config_dir / a[0]) if a else str(config_dir))
+    yield config_dir
+    pm.PathManager.user_config = original
+
+
+@pytest.fixture()
+def mock_compat_path(tmp_path):
+    """Patch STEAM_COMPATIBILITY_PATH to point to a controlled directory.
+
+    Returns (patched_path, original_path).
+    """
+    from fungus import proton_manager as pm
+
+    compat_dir = tmp_path / "compatibilitytools.d"
+    compat_dir.mkdir()
+    original = pm.STEAM_COMPATIBILITY_PATH
+    pm.STEAM_COMPATIBILITY_PATH = compat_dir
+    yield compat_dir
+    pm.STEAM_COMPATIBILITY_PATH = original
+
+
+# ---------------------------------------------------------------------------
+# _cache_key
+# ---------------------------------------------------------------------------
+
+
+class TestCacheKey:
+    """Tests for fungus.proton_manager._cache_key."""
+
+    def test_deterministic(self):
+        """Same URL always produces the same key."""
+        from fungus.proton_manager import _cache_key
+
+        key1 = _cache_key("https://example.com/releases")
+        key2 = _cache_key("https://example.com/releases")
+        assert key1 == key2
+
+    def test_different_urls_different_keys(self):
+        from fungus.proton_manager import _cache_key
+
+        key1 = _cache_key("https://url-a.com/releases")
+        key2 = _cache_key("https://url-b.com/releases")
+        assert key1 != key2
+
+    def test_safe_filename(self):
+        """Key should be a safe filename (prefix + hex hash + .json)."""
+        from fungus.proton_manager import _cache_key
+
+        key = _cache_key("https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases")
+        assert key.startswith("proton-releases-")
+        assert key.endswith(".json")
+        hash_part = key[len("proton-releases-"):-len(".json")]
+        assert all(c in "0123456789abcdef" for c in hash_part)
+        assert len(hash_part) == 16
+
+    def test_empty_url(self):
+        from fungus.proton_manager import _cache_key
+
+        key = _cache_key("")
+        assert key.startswith("proton-releases-")
+
+
+# ---------------------------------------------------------------------------
+# get_arch_asset
+# ---------------------------------------------------------------------------
+
+
+class TestGetArchAsset:
+    """Tests for fungus.proton_manager.get_arch_asset."""
+
+    def _make_asset(self, name, size=1234):
+        return {"name": name, "size": size}
+
+    def test_exact_arch_match(self):
+        """Asset with arch suffix is selected first."""
+        from fungus.proton_manager import get_arch_asset
+
+        assets = [
+            self._make_asset("GE-Proton11-1.tar.gz"),
+            self._make_asset("GE-Proton11-1-x86_64.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1-x86_64.tar.gz"
+
+    def test_aarch64_exact_match(self, monkeypatch):
+        """On aarch64, the -aarch64 asset is selected."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "aarch64")
+        assets = [
+            self._make_asset("GE-Proton11-1.tar.gz"),
+            self._make_asset("GE-Proton11-1-aarch64.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1-aarch64.tar.gz"
+
+    def test_default_build_for_x86_64(self, monkeypatch):
+        """On x86_64, the default build (no arch suffix) is selected
+        when no explicit arch match exists."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "x86_64")
+        assets = [
+            self._make_asset("GE-Proton11-1-aarch64.tar.gz"),
+            self._make_asset("GE-Proton11-1.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1.tar.gz"
+
+    def test_default_build_not_selected_when_aarch64_exists(self, monkeypatch):
+        """On x86_64, the default build is NOT selected if an aarch64
+        variant is available (it's a false match)."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "x86_64")
+        assets = [
+            self._make_asset("GE-Proton11-1-aarch64.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        # Falls through to fallback (first tar archive)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1-aarch64.tar.gz"
+
+    def test_fallback_to_first_tar(self, monkeypatch):
+        """When no arch match, returns the first tar archive."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "armv7l")
+        assets = [
+            self._make_asset("GE-Proton11-1.tar.gz"),
+            self._make_asset("GE-Proton11-1-x86_64.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1.tar.gz"
+
+    def test_no_matching_extensions_returns_none(self):
+        """No tar.gz/tar.xz assets → None."""
+        from fungus.proton_manager import get_arch_asset
+
+        assets = [
+            self._make_asset("GE-Proton11-1.zip"),
+            self._make_asset("GE-Proton11-1.sha256"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is None
+
+    def test_empty_list_returns_none(self):
+        from fungus.proton_manager import get_arch_asset
+
+        result = get_arch_asset([])
+        assert result is None
+
+    def test_tar_xz_extension(self, monkeypatch):
+        """Works with .tar.xz files too."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "x86_64")
+        assets = [
+            self._make_asset("GE-Proton11-1-x86_64.tar.xz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1-x86_64.tar.xz"
+
+    def test_exact_arch_preferred_over_default(self, monkeypatch):
+        """Explicit arch match is always preferred over default build."""
+        from fungus.proton_manager import get_arch_asset
+
+        monkeypatch.setattr("fungus.proton_manager.MACHINE_ARCH", "x86_64")
+        assets = [
+            self._make_asset("GE-Proton11-1.tar.gz"),
+            self._make_asset("GE-Proton11-1-x86_64.tar.gz"),
+            self._make_asset("GE-Proton11-1-aarch64.tar.gz"),
+        ]
+        result = get_arch_asset(assets)
+        assert result is not None
+        assert result["name"] == "GE-Proton11-1-x86_64.tar.gz"
+
+
+# ---------------------------------------------------------------------------
+# get_cache_dir
+# ---------------------------------------------------------------------------
+
+
+class TestGetCacheDir:
+    """Tests for fungus.proton_manager.get_cache_dir."""
+
+    def test_creates_cache_directory(self, mock_user_config):
+        from fungus.proton_manager import get_cache_dir
+
+        result = get_cache_dir()
+        assert result.exists()
+        assert result.is_dir()
+        assert result.name == "cache"
+
+    def test_returns_correct_path(self, mock_user_config):
+        from fungus.proton_manager import get_cache_dir
+
+        result = get_cache_dir()
+        assert str(result).startswith(str(mock_user_config))
+        assert result.name == "cache"
+
+
+# ---------------------------------------------------------------------------
+# clear_cache
+# ---------------------------------------------------------------------------
+
+
+class TestClearCache:
+    """Tests for fungus.proton_manager.clear_cache."""
+
+    def test_clears_specific_url(self, mock_user_config):
+        from fungus.proton_manager import _cache_key, clear_cache, get_cache_dir
+
+        cache_dir = get_cache_dir()
+        # Create a fake cache file
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        cache_file.write_text("{}")
+        assert cache_file.exists()
+
+        clear_cache(["https://example.com/releases"])
+        assert not cache_file.exists()
+
+    def test_clears_all_urls_by_default(self, mock_user_config):
+        """Calling clear_cache() with no args clears all known upstreams."""
+        from fungus.proton_manager import (
+            DEFAULT_UPSTREAM_URLS,
+            _cache_key,
+            clear_cache,
+            get_cache_dir,
+        )
+
+        cache_dir = get_cache_dir()
+        # Create fake cache files for all upstreams
+        for url in DEFAULT_UPSTREAM_URLS:
+            (cache_dir / _cache_key(url)).write_text("{}")
+
+        clear_cache()
+        for url in DEFAULT_UPSTREAM_URLS:
+            assert not (cache_dir / _cache_key(url)).exists()
+
+    def test_clears_nonexistent_file_is_noop(self, mock_user_config):
+        """Clearing a cache file that doesn't exist is a no-op."""
+        from fungus.proton_manager import clear_cache
+
+        # Should not raise
+        clear_cache(["https://nonexistent.com/releases"])
+
+    def test_clears_corrupt_file(self, mock_user_config):
+        """Corrupt cache files are still removed."""
+        from fungus.proton_manager import _cache_key, clear_cache, get_cache_dir
+
+        cache_dir = get_cache_dir()
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        cache_file.write_text("not json {{{")
+        assert cache_file.exists()
+
+        clear_cache(["https://example.com/releases"])
+        assert not cache_file.exists()
+
+
+# ---------------------------------------------------------------------------
+# get_installed_path
+# ---------------------------------------------------------------------------
+
+
+class TestGetInstalledPath:
+    """Tests for fungus.proton_manager.get_installed_path."""
+
+    def test_exact_match(self, mock_compat_path):
+        """Existing directory with matching name is returned."""
+        from fungus.proton_manager import get_installed_path
+
+        (mock_compat_path / "GE-Proton11-1").mkdir()
+        result = get_installed_path("GE-Proton11-1")
+        assert str(result).endswith("GE-Proton11-1")
+
+    def test_ends_with_match(self, mock_compat_path):
+        """Directory ending with tag name is matched."""
+        from fungus.proton_manager import get_installed_path
+
+        (mock_compat_path / "my-GE-Proton11-1").mkdir()
+        result = get_installed_path("GE-Proton11-1")
+        assert str(result).endswith("my-GE-Proton11-1")
+
+    def test_proton_prefix_match(self, mock_compat_path):
+        """'proton-11' matches folder ending with 'proton-11' suffix."""
+        from fungus.proton_manager import get_installed_path
+
+        # Folder must end with 'proton-11' for the endswith check to match
+        (mock_compat_path / "my-proton-11").mkdir()
+        result = get_installed_path("proton-11")
+        assert str(result).endswith("my-proton-11")
+
+    def test_no_match_returns_expected_path(self, mock_compat_path):
+        """No matching directory → returns expected path."""
+        from fungus.proton_manager import get_installed_path
+
+        result = get_installed_path("NonExistent")
+        assert str(result).endswith("NonExistent")
+
+    def test_case_insensitive(self, mock_compat_path):
+        """Matching is case-insensitive."""
+        from fungus.proton_manager import get_installed_path
+
+        (mock_compat_path / "ge-proton11-1").mkdir()
+        result = get_installed_path("GE-Proton11-1")
+        assert str(result).endswith("ge-proton11-1")
+
+    def test_empty_compat_dir(self, mock_compat_path):
+        """Empty compatibilitytools.d → returns expected path."""
+        from fungus.proton_manager import get_installed_path
+
+        result = get_installed_path("GE-Proton11-1")
+        assert str(result).endswith("GE-Proton11-1")
+
+
+# ---------------------------------------------------------------------------
+# remove_path
+# ---------------------------------------------------------------------------
+
+
+class TestRemovePath:
+    """Tests for fungus.proton_manager.remove_path."""
+
+    def test_removes_existing_directory(self, tmp_path):
+        from fungus.proton_manager import remove_path
+
+        target = tmp_path / "to_remove"
+        target.mkdir()
+        (target / "file.txt").write_text("data")
+        assert target.exists()
+
+        remove_path(str(target))
+        assert not target.exists()
+
+    def test_noop_on_nonexistent_path(self, tmp_path):
+        """Removing a non-existent path is a no-op."""
+        from fungus.proton_manager import remove_path
+
+        # Should not raise
+        remove_path(str(tmp_path / "does_not_exist"))
+
+    def test_noop_on_empty_string(self):
+        from fungus.proton_manager import remove_path
+
+        # Should not raise
+        remove_path("")
+
+    def test_noop_on_none(self):
+        from fungus.proton_manager import remove_path
+
+        # Should not raise
+        remove_path(None)
+
+
+# ---------------------------------------------------------------------------
+# fetch_releases
+# ---------------------------------------------------------------------------
+
+
+def _mock_response(status_code, json_data):
+    """Create a mock requests.Response."""
+    resp = MagicMock()
+    resp.status_code = status_code
+    resp.json.return_value = json_data
+    return resp
+
+
+def _make_release(tag_name, assets=None):
+    """Create a mock release dict."""
+    if assets is None:
+        assets = []
+    return {
+        "tag_name": tag_name,
+        "assets": assets,
+    }
+
+
+def _make_asset(name):
+    return {"name": name, "size": 1234}
+
+
+class TestFetchReleases:
+    """Tests for fungus.proton_manager.fetch_releases (mocked requests.get)."""
+
+    def _fetch_with_mocked_requests(self, url, responses):
+        """Helper to call fetch_releases with mocked requests.get."""
+        with patch("fungus.proton_manager.requests.get", side_effect=responses):
+            from fungus.proton_manager import fetch_releases
+            return fetch_releases(url)
+
+    def test_single_page_ge_proton(self):
+        """Single page of GE-Proton releases is fetched and filtered."""
+        releases = [
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.tar.gz")]),
+            _make_release("GE-Proton10-1", [_make_asset("GE-Proton10-1.tar.gz")]),
+            _make_release("GE-Proton9-11", [_make_asset("GE-Proton9-11.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 3
+        tags = [r["tag_name"] for r in result]
+        assert "GE-Proton11-1" in tags
+        assert "GE-Proton10-1" in tags
+        assert "GE-Proton9-11" in tags
+
+    def test_skips_old_ge_proton_versions(self):
+        """GE-Proton versions < 9.1 are filtered out."""
+        releases = [
+            _make_release("GE-Proton8-22", [_make_asset("GE-Proton8-22.tar.gz")]),
+            _make_release("GE-Proton9-0", [_make_asset("GE-Proton9-0.tar.gz")]),
+            _make_release("GE-Proton9-1", [_make_asset("GE-Proton9-1.tar.gz")]),
+            _make_release("GE-Proton9-2", [_make_asset("GE-Proton9-2.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 2
+        tags = [r["tag_name"] for r in result]
+        assert "GE-Proton9-1" in tags
+        assert "GE-Proton9-2" in tags
+
+    def test_skips_non_ge_proton_releases(self):
+        """Non-GE-Proton releases are filtered out."""
+        releases = [
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.tar.gz")]),
+            _make_release("SomeOther-1.0", [_make_asset("SomeOther-1.0.tar.gz")]),
+            _make_release("Proton-11.0-1", [_make_asset("Proton-11.0-1.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 1
+        assert result[0]["tag_name"] == "GE-Proton11-1"
+
+    def test_skips_releases_without_tar_assets(self):
+        """Releases without .tar.gz/.tar.xz assets are filtered out."""
+        releases = [
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.zip")]),
+            _make_release("GE-Proton11-2", [_make_asset("GE-Proton11-2.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 1
+        assert result[0]["tag_name"] == "GE-Proton11-2"
+
+    def test_duplicate_tags_deduplicated(self):
+        """Duplicate tag names are deduplicated (first wins)."""
+        releases = [
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.tar.gz")]),
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1-v2.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 1
+        assert result[0]["tag_name"] == "GE-Proton11-1"
+
+    def test_etaash_em_releases(self):
+        """EM releases from Etaash-mathamsetty are filtered correctly."""
+        releases = [
+            _make_release("EM-1.0", [_make_asset("EM-1.0.tar.gz")]),
+            _make_release("EM-2.0", [_make_asset("EM-2.0.tar.gz")]),
+            _make_release("Other-1.0", [_make_asset("Other-1.0.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/Etaash-mathamsetty/Proton/releases",
+            responses,
+        )
+        assert len(result) == 2
+        tags = [r["tag_name"] for r in result]
+        assert "EM-1.0" in tags
+        assert "EM-2.0" in tags
+
+    def test_rate_limit_raises_error(self):
+        """403 with rate limit message raises RateLimitError."""
+        from fungus.proton_manager import RateLimitError
+
+        rate_limited = _mock_response(
+            403,
+            {"message": "API rate limit exceeded"},
+        )
+        responses = [rate_limited]
+
+        with patch("fungus.proton_manager.requests.get", side_effect=responses):
+            with pytest.raises(RateLimitError, match="rate limit"):
+                from fungus.proton_manager import fetch_releases
+                fetch_releases("https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases")
+
+    def test_empty_response_breaks_loop(self):
+        """Empty response list ends pagination."""
+        responses = [_mock_response(200, []), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert result == []
+
+    def test_two_page_pagination(self):
+        """Multi-page releases are fetched and combined."""
+        page1 = [
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.tar.gz")]),
+        ]
+        page2 = [
+            _make_release("GE-Proton10-1", [_make_asset("GE-Proton10-1.tar.gz")]),
+        ]
+        responses = [
+            _mock_response(200, page1),
+            _mock_response(200, page2),
+            _mock_response(200, []),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 2
+
+    def test_non_200_status_breaks_loop(self):
+        """Non-200 status code ends the fetch loop."""
+        responses = [
+            _mock_response(500, {"error": "server error"}),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert result == []
+
+    def test_ge_proton_version_parse_error_skipped(self):
+        """Malformed tag names that can't be parsed are skipped."""
+        releases = [
+            _make_release("GE-Proton", [_make_asset("GE-Proton.tar.gz")]),
+            _make_release("GE-Proton11-1", [_make_asset("GE-Proton11-1.tar.gz")]),
+        ]
+        responses = [_mock_response(200, releases), _mock_response(200, [])]
+
+        result = self._fetch_with_mocked_requests(
+            "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases",
+            responses,
+        )
+        assert len(result) == 1
+        assert result[0]["tag_name"] == "GE-Proton11-1"
+
+
+# ---------------------------------------------------------------------------
+# _fetch_with_cache
+# ---------------------------------------------------------------------------
+
+
+class TestFetchWithCache:
+    """Tests for fungus.proton_manager._fetch_with_cache."""
+
+    def _fetch_with_mocked_requests(self, url, cache_dir, responses):
+        """Helper to call _fetch_with_cache with mocked requests.get."""
+        with patch("fungus.proton_manager.requests.get", side_effect=responses):
+            from fungus.proton_manager import _fetch_with_cache
+            return _fetch_with_cache(url, cache_dir=cache_dir)
+
+    def test_cache_hit_returns_cached_data(self, tmp_path):
+        """Valid cached data is returned without calling network."""
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        from fungus.proton_manager import _cache_key
+
+        cached_data = [
+            {"tag_name": "GE-Proton11-1", "assets": []},
+        ]
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        import time
+        cache_file.write_text(json.dumps({"time": time.time(), "data": cached_data}))
+
+        # requests.get should NOT be called
+        with patch("fungus.proton_manager.requests.get") as mock_get:
+            result = self._fetch_with_mocked_requests(
+                "https://example.com/releases", cache_dir, []
+            )
+
+        assert result == cached_data
+        mock_get.assert_not_called()
+
+    def test_cache_expired_fetches_fresh(self, tmp_path):
+        """Expired cached data triggers a fresh fetch."""
+        import time
+
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        from fungus.proton_manager import _cache_key, CACHE_TTL
+
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        cache_file.write_text(
+            json.dumps({"time": time.time() - CACHE_TTL - 100, "data": []})
+        )
+
+        # Must include tar.gz asset so fetch_releases doesn't filter it out
+        fresh_data = [
+            {"tag_name": "GE-Proton11-1", "assets": [{"name": "GE-Proton11-1.tar.gz"}]},
+        ]
+        # fetch_releases calls requests.get twice (pagination loop: page 1 + empty page 2)
+        responses = [
+            _mock_response(200, fresh_data),
+            _mock_response(200, []),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://example.com/releases", cache_dir, responses
+        )
+        assert result == fresh_data
+
+    def test_corrupt_cache_ignored(self, tmp_path):
+        """Corrupt cache file is ignored and fresh data is fetched."""
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        from fungus.proton_manager import _cache_key
+
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        cache_file.write_text("not valid json {{{")
+
+        # Must include tar.gz asset so fetch_releases doesn't filter it out
+        fresh_data = [
+            {"tag_name": "GE-Proton11-1", "assets": [{"name": "GE-Proton11-1.tar.gz"}]},
+        ]
+        # fetch_releases calls requests.get twice (pagination loop)
+        responses = [
+            _mock_response(200, fresh_data),
+            _mock_response(200, []),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://example.com/releases", cache_dir, responses
+        )
+        assert result == fresh_data
+
+    def test_cache_miss_fetches_fresh(self, tmp_path):
+        """No cache file → fresh fetch."""
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        # Must include tar.gz asset so fetch_releases doesn't filter it out
+        fresh_data = [
+            {"tag_name": "GE-Proton11-1", "assets": [{"name": "GE-Proton11-1.tar.gz"}]},
+        ]
+        # fetch_releases calls requests.get twice (pagination loop)
+        responses = [
+            _mock_response(200, fresh_data),
+            _mock_response(200, []),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://example.com/releases", cache_dir, responses
+        )
+        assert result == fresh_data
+
+    def test_cache_write_after_fetch(self, tmp_path):
+        """Fetched data is saved to cache."""
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        # Must include tar.gz asset so fetch_releases doesn't filter it out
+        fresh_data = [
+            {"tag_name": "GE-Proton11-1", "assets": [{"name": "GE-Proton11-1.tar.gz"}]},
+        ]
+        # fetch_releases calls requests.get twice (pagination loop)
+        responses = [
+            _mock_response(200, fresh_data),
+            _mock_response(200, []),
+        ]
+
+        self._fetch_with_mocked_requests(
+            "https://example.com/releases", cache_dir, responses
+        )
+
+        from fungus.proton_manager import _cache_key
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        assert cache_file.exists()
+        data = json.loads(cache_file.read_text())
+        assert data["data"] == fresh_data
+
+    def test_cache_read_error_continues(self, tmp_path):
+        """KeyError on cache read falls through to fetch."""
+        cache_dir = tmp_path / "cache"
+        cache_dir.mkdir()
+
+        from fungus.proton_manager import _cache_key
+
+        # Valid JSON but missing 'data' key → KeyError → falls through
+        cache_file = cache_dir / _cache_key("https://example.com/releases")
+        cache_file.write_text('{"time": 0}')
+
+        # Must include tar.gz asset so fetch_releases doesn't filter it out
+        fresh_data = [
+            {"tag_name": "GE-Proton11-1", "assets": [{"name": "GE-Proton11-1.tar.gz"}]},
+        ]
+        # fetch_releases calls requests.get twice (pagination loop)
+        responses = [
+            _mock_response(200, fresh_data),
+            _mock_response(200, []),
+        ]
+
+        result = self._fetch_with_mocked_requests(
+            "https://example.com/releases", cache_dir, responses
+        )
+        assert result == fresh_data
diff --git a/tests/test_umu_manager.py b/tests/test_umu_manager.py
new file mode 100644
index 0000000..293622c
--- /dev/null
+++ b/tests/test_umu_manager.py
@@ -0,0 +1,881 @@
+"""Tests for fungus.umu_manager — UMU-Launcher installation and update management."""
+
+import io
+import os
+import re
+import subprocess
+import tarfile
+import tempfile
+from pathlib import Path
+from unittest.mock import MagicMock, patch
+
+import pytest
+
+# ---------------------------------------------------------------------------
+# Helpers
+# ---------------------------------------------------------------------------
+
+
+def _make_tar_bytes(version: str = "1.4.0") -> bytes:
+    """Create a tar archive containing ``umu/umu-run`` as bytes."""
+    buf = tempfile.NamedTemporaryFile(suffix=".tar", delete=False)
+    buf.close()
+    with tarfile.open(buf.name, "w:") as tar:
+        data = b"#!/bin/bash\necho umu-run\n"
+        # The source code extracts with tar.extractfile("umu/umu-run")
+        info = tarfile.TarInfo(name="umu/umu-run")
+        info.size = len(data)
+        info.mode = 0o755
+        tar.addfile(info, fileobj=io.BytesIO(data))
+    with open(buf.name, "rb") as f:
+        tar_bytes = f.read()
+    os.remove(buf.name)
+    return tar_bytes
+
+
+def _make_bad_tar_bytes() -> bytes:
+    """Create a tar archive WITHOUT umu/umu-run."""
+    buf = tempfile.NamedTemporaryFile(suffix=".tar", delete=False)
+    buf.close()
+    with tarfile.open(buf.name, "w:") as tar:
+        data = b"wrong content"
+        info = tarfile.TarInfo(name="wrong/path/file.txt")
+        info.size = len(data)
+        tar.addfile(info, fileobj=io.BytesIO(data))
+    with open(buf.name, "rb") as f:
+        tar_bytes = f.read()
+    os.remove(buf.name)
+    return tar_bytes
+
+
+# ---------------------------------------------------------------------------
+# Fixtures
+# ---------------------------------------------------------------------------
+
+
+@pytest.fixture()
+def umu_install_dir(tmp_path):
+    """Provide a temporary UMU install directory and patch module-level constants."""
+    install_dir = tmp_path / "fungus-launcher"
+    install_dir.mkdir()
+
+    with patch("fungus.umu_manager.UMU_INSTALL_DIR", str(install_dir)):
+        with patch("fungus.umu_manager.UMU_VERSION_FILE", str(install_dir / "version.txt")):
+            with patch("fungus.umu_manager.UMU_BIN_PATH", str(install_dir / "umu-run")):
+                with patch("fungus.umu_manager.STEAMRT_CHECK_FILE", str(install_dir / "steamrt.txt")):
+                    yield install_dir
+
+
+@pytest.fixture()
+def mock_requests_get():
+    """Provide a mock for requests.get that can be configured per-test."""
+    with patch("fungus.umu_manager.requests.get") as mock_get:
+        yield mock_get
+
+
+@pytest.fixture()
+def fake_proton_path(umu_install_dir):
+    """Create a fake Proton directory under the temp data dir.
+
+    The update_steam_runtime function builds the proton path from XDG_DATA_HOME
+    (or ~/.local/share).  We patch that so the directory exists under tmp_path.
+    """
+    share_dir = umu_install_dir / "Steam" / "compatibilitytools.d"
+    share_dir.mkdir(parents=True, exist_ok=True)
+
+    with patch.dict(os.environ, {"XDG_DATA_HOME": str(umu_install_dir)}):
+        yield share_dir
+
+
+# ---------------------------------------------------------------------------
+# Test get_umu_run_path
+# ---------------------------------------------------------------------------
+
+
+class TestGetUmuRunPath:
+    def test_returns_path_from_constants(self):
+        """get_umu_run_path should return the umu_run path from constants."""
+        from fungus.umu_manager import get_umu_run_path
+
+        with patch("fungus.constants.umu_run", Path("/custom/path/umu-run")):
+            result = get_umu_run_path()
+            assert result == "/custom/path/umu-run"
+
+    def test_returns_string(self):
+        """The result should be a string, not a Path object."""
+        from fungus.umu_manager import get_umu_run_path
+
+        with patch("fungus.constants.umu_run", Path("/some/path")):
+            result = get_umu_run_path()
+            assert isinstance(result, str)
+
+
+# ---------------------------------------------------------------------------
+# Test get_latest_umu_version
+# ---------------------------------------------------------------------------
+
+
+class TestGetLatestUmuVersion:
+    def test_returns_tag_on_success(self, mock_requests_get):
+        """Should return the tag_name from the first release."""
+        from fungus.umu_manager import get_latest_umu_version
+
+        mock_requests_get.return_value = MagicMock(
+            status_code=200,
+            json=lambda: [{"tag_name": "1.4.0"}],
+            text="ok",
+        )
+
+        result = get_latest_umu_version()
+        assert result == "1.4.0"
+
+    def test_returns_none_on_empty_releases(self, mock_requests_get):
+        """Should return None when the releases list is empty."""
+        from fungus.umu_manager import get_latest_umu_version
+
+        mock_requests_get.return_value = MagicMock(
+            status_code=200,
+            json=lambda: [],
+            text="",
+        )
+
+        result = get_latest_umu_version()
+        assert result is None
+
+    def test_returns_none_on_non_200_status(self, mock_requests_get):
+        """Should return None when the API returns a non-200 status."""
+        from fungus.umu_manager import get_latest_umu_version
+
+        mock_requests_get.return_value = MagicMock(
+            status_code=403,
+            json=lambda: [],
+            text="forbidden",
+        )
+
+        result = get_latest_umu_version()
+        assert result is None
+
+    def test_returns_none_on_request_exception(self, mock_requests_get):
+        """Should return None when requests.get raises an exception."""
+        from fungus.umu_manager import get_latest_umu_version
+
+        mock_requests_get.side_effect = Exception("network error")
+
+        result = get_latest_umu_version()
+        assert result is None
+
+    def test_calls_api_with_timeout(self, mock_requests_get):
+        """Should pass a timeout to requests.get."""
+        from fungus.umu_manager import get_latest_umu_version
+
+        mock_requests_get.return_value = MagicMock(
+            status_code=200,
+            json=lambda: [{"tag_name": "1.0.0"}],
+            text="ok",
+        )
+
+        get_latest_umu_version()
+        mock_requests_get.assert_called_once()
+        call_kwargs = mock_requests_get.call_args[1]
+        assert call_kwargs.get("timeout") == 5
+
+
+# ---------------------------------------------------------------------------
+# Test get_installed_umu_version
+# ---------------------------------------------------------------------------
+
+
+class TestGetInstalledUmuVersion:
+    def test_returns_version_from_file(self, umu_install_dir):
+        """Should return the version string from the version file."""
+        version_file = umu_install_dir / "version.txt"
+        version_file.write_text("1.4.0", encoding="utf-8")
+
+        from fungus.umu_manager import get_installed_umu_version
+
+        result = get_installed_umu_version()
+        assert result == "1.4.0"
+
+    def test_strips_whitespace(self, umu_install_dir):
+        """Should strip leading/trailing whitespace from the version file."""
+        version_file = umu_install_dir / "version.txt"
+        version_file.write_text("  1.3.0  \n", encoding="utf-8")
+
+        from fungus.umu_manager import get_installed_umu_version
+
+        result = get_installed_umu_version()
+        assert result == "1.3.0"
+
+    def test_returns_none_when_file_missing(self, umu_install_dir):
+        """Should return None when the version file does not exist."""
+        from fungus.umu_manager import get_installed_umu_version
+
+        result = get_installed_umu_version()
+        assert result is None
+
+
+# ---------------------------------------------------------------------------
+# Test is_umu_installed
+# ---------------------------------------------------------------------------
+
+
+class TestIsUmuInstalled:
+    def test_returns_true_when_binary_exists_and_executable(self, umu_install_dir):
+        """Should return True when the binary exists and is executable."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\necho hello\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+
+        from fungus.umu_manager import is_umu_installed
+
+        assert is_umu_installed() is True
+
+    def test_returns_false_when_binary_missing(self, umu_install_dir):
+        """Should return False when the binary does not exist."""
+        from fungus.umu_manager import is_umu_installed
+
+        assert is_umu_installed() is False
+
+    def test_returns_false_when_not_executable(self, umu_install_dir):
+        """Should return False when the binary exists but is not executable."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\necho hello\n", encoding="utf-8")
+        bin_path.chmod(0o644)
+
+        from fungus.umu_manager import is_umu_installed
+
+        assert is_umu_installed() is False
+
+
+# ---------------------------------------------------------------------------
+# Test get_steamrt_last_check
+# ---------------------------------------------------------------------------
+
+
+class TestGetSteamrtLastCheck:
+    def test_returns_timestamp_from_file(self, umu_install_dir):
+        """Should return the timestamp string from the file."""
+        check_file = umu_install_dir / "steamrt.txt"
+        check_file.write_text("2025-07-01 14:30", encoding="utf-8")
+
+        from fungus.umu_manager import get_steamrt_last_check
+
+        result = get_steamrt_last_check()
+        assert result == "2025-07-01 14:30"
+
+    def test_returns_none_when_file_missing(self, umu_install_dir):
+        """Should return None when the check file does not exist."""
+        from fungus.umu_manager import get_steamrt_last_check
+
+        result = get_steamrt_last_check()
+        assert result is None
+
+    def test_returns_none_when_file_empty(self, umu_install_dir):
+        """Should return None when the file exists but is empty."""
+        check_file = umu_install_dir / "steamrt.txt"
+        check_file.write_text("", encoding="utf-8")
+
+        from fungus.umu_manager import get_steamrt_last_check
+
+        result = get_steamrt_last_check()
+        assert result is None
+
+    def test_returns_none_on_os_error(self, umu_install_dir):
+        """Should return None when reading the file raises an OSError."""
+        check_file = umu_install_dir / "steamrt.txt"
+        check_file.write_text("2025-07-01 14:30", encoding="utf-8")
+
+        with patch("builtins.open", side_effect=OSError("permission denied")):
+            from fungus.umu_manager import get_steamrt_last_check
+            result = get_steamrt_last_check()
+            assert result is None
+
+
+# ---------------------------------------------------------------------------
+# Test save_steamrt_last_check
+# ---------------------------------------------------------------------------
+
+
+class TestSaveSteamrtLastCheck:
+    def test_writes_timestamp_and_returns_true(self, umu_install_dir):
+        """Should write a timestamp and return True on success."""
+        from fungus.umu_manager import save_steamrt_last_check
+
+        result = save_steamrt_last_check()
+        assert result is True
+
+        check_file = umu_install_dir / "steamrt.txt"
+        assert check_file.exists()
+        content = check_file.read_text(encoding="utf-8").strip()
+        # Should match YYYY-MM-DD HH:MM format
+        assert re.match(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}", content)
+
+    def test_creates_directory_if_missing(self, umu_install_dir):
+        """Should create the install directory if it does not exist."""
+        import shutil
+        shutil.rmtree(umu_install_dir)
+
+        with patch("fungus.umu_manager.UMU_INSTALL_DIR", str(umu_install_dir)):
+            with patch("fungus.umu_manager.STEAMRT_CHECK_FILE", str(umu_install_dir / "steamrt.txt")):
+                from fungus.umu_manager import save_steamrt_last_check
+                result = save_steamrt_last_check()
+                assert result is True
+                assert umu_install_dir.exists()
+
+    def test_returns_false_on_os_error(self, umu_install_dir):
+        """Should return False when writing raises an OSError."""
+        with patch("builtins.open", side_effect=OSError("permission denied")):
+            with patch("os.makedirs", side_effect=OSError("permission denied")):
+                from fungus.umu_manager import save_steamrt_last_check
+                result = save_steamrt_last_check()
+                assert result is False
+
+
+# ---------------------------------------------------------------------------
+# Test download_umu_run
+# ---------------------------------------------------------------------------
+
+
+class TestDownloadUmuRun:
+    def test_successful_download_and_install(self, umu_install_dir, mock_requests_get):
+        """Should download, extract, and install umu-run successfully."""
+        tar_bytes = _make_tar_bytes()
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        from fungus.umu_manager import download_umu_run
+
+        result = download_umu_run("1.4.0")
+        assert result is True
+
+        bin_path = umu_install_dir / "umu-run"
+        assert bin_path.exists()
+        assert os.access(str(bin_path), os.X_OK)
+
+        version_file = umu_install_dir / "version.txt"
+        assert version_file.read_text(encoding="utf-8").strip() == "1.4.0"
+
+    def test_returns_false_on_non_200_response(self, umu_install_dir, mock_requests_get):
+        """Should return False when the download returns a non-200 status."""
+        mock_requests_get.return_value = MagicMock(
+            status_code=404,
+            headers={},
+            text="not found",
+        )
+
+        from fungus.umu_manager import download_umu_run
+
+        result = download_umu_run("9.9.9")
+        assert result is False
+
+    def test_returns_false_on_request_exception(self, umu_install_dir, mock_requests_get):
+        """Should return False when the download request fails."""
+        mock_requests_get.side_effect = Exception("connection refused")
+
+        from fungus.umu_manager import download_umu_run
+
+        result = download_umu_run("1.4.0")
+        assert result is False
+
+    def test_returns_false_when_tar_missing_member(self, umu_install_dir, mock_requests_get):
+        """Should return False when the tar archive doesn't contain umu/umu-run."""
+        tar_bytes = _make_bad_tar_bytes()
+
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        from fungus.umu_manager import download_umu_run
+
+        result = download_umu_run("1.4.0")
+        assert result is False
+
+    def test_calls_progress_callback(self, umu_install_dir, mock_requests_get):
+        """Should call the progress callback with percentage values."""
+        tar_bytes = _make_tar_bytes()
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        callback = MagicMock()
+
+        from fungus.umu_manager import download_umu_run
+
+        download_umu_run("1.4.0", progress_callback=callback)
+
+        callback.assert_called()
+        # Should have been called with 100 at the end
+        calls = [c[0][0] for c in callback.call_args_list]
+        assert 100 in calls
+
+    def test_returns_false_on_chmod_failure(self, umu_install_dir, mock_requests_get):
+        """Should return False if setting executable permission fails."""
+        tar_bytes = _make_tar_bytes()
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        with patch("os.chmod", side_effect=OSError("permission denied")):
+            from fungus.umu_manager import download_umu_run
+            result = download_umu_run("1.4.0")
+            assert result is False
+
+    def test_returns_false_on_version_file_write_failure(self, umu_install_dir, mock_requests_get):
+        """Should return False if writing the version file fails."""
+        tar_bytes = _make_tar_bytes()
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        # Patch only the open call that writes the version file
+        original_open = open
+        def failing_open(*args, **kwargs):
+            if args and "version.txt" in str(args[0]):
+                raise OSError("disk full")
+            return original_open(*args, **kwargs)
+
+        with patch("builtins.open", failing_open):
+            from fungus.umu_manager import download_umu_run
+            result = download_umu_run("1.4.0")
+            assert result is False
+
+    def test_creates_install_directory(self, umu_install_dir, mock_requests_get):
+        """Should create the install directory if it doesn't exist."""
+        import shutil
+        shutil.rmtree(umu_install_dir)
+
+        tar_bytes = _make_tar_bytes()
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        from fungus.umu_manager import download_umu_run
+        result = download_umu_run("1.4.0")
+        assert result is True
+        assert umu_install_dir.exists()
+
+    def test_cleans_up_temp_file_on_failure(self, umu_install_dir, mock_requests_get):
+        """Should clean up the temporary download file on failure."""
+        mock_requests_get.return_value = MagicMock(status_code=404, headers={}, text="not found")
+
+        from fungus.umu_manager import download_umu_run
+
+        download_umu_run("9.9.9")
+
+        # No temp files should remain in /tmp matching our pattern
+        # (hard to verify precisely, but at least it shouldn't crash)
+
+
+# ---------------------------------------------------------------------------
+# Test check_and_install_if_needed
+# ---------------------------------------------------------------------------
+
+
+class TestCheckAndInstallIfNeeded:
+    def test_up_to_date(self, umu_install_dir):
+        """Should return (True, 'up_to_date') when already at the latest version."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+        (umu_install_dir / "version.txt").write_text("1.4.0", encoding="utf-8")
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result == (True, "up_to_date")
+
+    def test_updates_when_outdated(self, umu_install_dir, mock_requests_get):
+        """Should download and update when a newer version is available."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+        (umu_install_dir / "version.txt").write_text("1.3.0", encoding="utf-8")
+
+        tar_bytes = _make_tar_bytes("1.4.0")
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result[1] == "updated"
+            assert result[0] is True
+
+    def test_installs_when_not_installed(self, umu_install_dir, mock_requests_get):
+        """Should download and install when umu-run is not present."""
+        tar_bytes = _make_tar_bytes("1.4.0")
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result[1] == "installed"
+            assert result[0] is True
+
+    def test_returns_failed_when_latest_version_fetch_fails(self, umu_install_dir):
+        """Should return (False, 'failed') when the version API is unreachable."""
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value=None):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result == (False, "failed")
+
+    def test_returns_failed_when_update_download_fails(self, umu_install_dir, mock_requests_get):
+        """Should return (False, 'failed') when the download fails during update."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+        (umu_install_dir / "version.txt").write_text("1.3.0", encoding="utf-8")
+
+        mock_requests_get.return_value = MagicMock(status_code=404, headers={}, text="not found")
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result == (False, "failed")
+
+    def test_returns_failed_when_install_download_fails(self, umu_install_dir, mock_requests_get):
+        """Should return (False, 'failed') when the download fails during install."""
+        mock_requests_get.return_value = MagicMock(status_code=404, headers={}, text="not found")
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result == (False, "failed")
+
+    def test_returns_failed_when_latest_api_returns_none_during_update(self, umu_install_dir):
+        """Should return (False, 'failed') when API returns None during update check."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+        (umu_install_dir / "version.txt").write_text("1.3.0", encoding="utf-8")
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value=None):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            result = check_and_install_if_needed()
+            assert result == (False, "failed")
+
+    def test_calls_progress_callback_on_update(self, umu_install_dir, mock_requests_get):
+        """Progress callback should be forwarded during update."""
+        bin_path = umu_install_dir / "umu-run"
+        bin_path.write_text("#!/bin/bash\n", encoding="utf-8")
+        bin_path.chmod(0o755)
+        (umu_install_dir / "version.txt").write_text("1.3.0", encoding="utf-8")
+
+        tar_bytes = _make_tar_bytes("1.4.0")
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        callback = MagicMock()
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            check_and_install_if_needed(progress_callback=callback)
+
+            callback.assert_called()
+
+    def test_calls_progress_callback_on_install(self, umu_install_dir, mock_requests_get):
+        """Progress callback should be forwarded during initial install."""
+        tar_bytes = _make_tar_bytes("1.4.0")
+        mock_response = MagicMock()
+        mock_response.status_code = 200
+        mock_response.headers = {"content-length": str(len(tar_bytes))}
+        mock_response.iter_content.return_value = [tar_bytes]
+        mock_requests_get.return_value = mock_response
+
+        callback = MagicMock()
+
+        with patch("fungus.umu_manager.get_latest_umu_version", return_value="1.4.0"):
+            from fungus.umu_manager import check_and_install_if_needed
+
+            check_and_install_if_needed(progress_callback=callback)
+
+            callback.assert_called()
+
+
+# ---------------------------------------------------------------------------
+# Test update_steam_runtime
+# ---------------------------------------------------------------------------
+
+
+class TestUpdateSteamRuntime:
+    def test_returns_error_when_proton_path_not_found(self):
+        """Should return an error when the Proton directory does not exist."""
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            from fungus.umu_manager import update_steam_runtime
+
+            result = update_steam_runtime("Proton-9.0")
+            assert result[0] is False
+            assert "Proton path not found" in result[1]
+
+    def test_runs_wineprefixcreate_command(self, umu_install_dir, fake_proton_path):
+        """Should run umu-run with wineprefixcreate and correct env vars."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Already up to date\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime("Proton-9.0")
+                assert result[0] is True
+                assert result[1] == "Already up to date"
+
+                subprocess.Popen.assert_called_once()  # pyright: ignore[reportAttributeAccessIssue]
+                call_args = subprocess.Popen.call_args  # pyright: ignore[reportAttributeAccessIssue]
+                cmd = call_args[0][0]
+                assert cmd[0] == "/fake/umu-run"
+                assert "wineprefixcreate" in cmd
+                assert "/usr/bin/true" in cmd
+
+    def test_sets_proton_version_env(self, umu_install_dir, fake_proton_path):
+        """Should set PROTONVERSION env var for Proton 9.x."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("Proton-9.0")
+
+                call_kwargs = subprocess.Popen.call_args[1]  # pyright: ignore[reportAttributeAccessIssue]
+                env = call_kwargs["env"]
+                assert env.get("PROTONVERSION") == "9"
+
+    def test_sets_proton_version_env_for_proton_11(self, umu_install_dir, fake_proton_path):
+        """Should set PROTONVERSION for Proton 11.x."""
+        (fake_proton_path / "Proton-11.0-1").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("Proton-11.0-1")
+
+                call_kwargs = subprocess.Popen.call_args[1]  # pyright: ignore[reportAttributeAccessIssue]
+                env = call_kwargs["env"]
+                assert env.get("PROTONVERSION") == "11"
+
+    def test_does_not_set_proton_version_for_unknown_format(self, umu_install_dir, fake_proton_path):
+        """Should not set PROTONVERSION if version cannot be parsed."""
+        (fake_proton_path / "UnknownFormat").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("UnknownFormat")
+
+                call_kwargs = subprocess.Popen.call_args[1]  # pyright: ignore[reportAttributeAccessIssue]
+                env = call_kwargs["env"]
+                assert "PROTONVERSION" not in env
+
+    def test_returns_update_ok_on_success(self, umu_install_dir, fake_proton_path):
+        """Should return (True, 'Update OK') on successful runtime update."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Downloading steamrt...\n", "Extracting...\n", "Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime("Proton-9.0")
+                assert result == (True, "Update OK")
+
+    def test_calls_progress_callback_on_download(self, umu_install_dir, fake_proton_path):
+        """Progress callback should be called when Downloading/Extracting is seen."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Downloading steamrt...\n", "Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        callback = MagicMock()
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("Proton-9.0", progress_callback=callback)
+
+                callback.assert_any_call(50)
+
+    def test_calls_on_success_callback(self, umu_install_dir, fake_proton_path):
+        """on_success callback should be called on 'Already up to date'."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Already up to date\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        on_success = MagicMock()
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime(
+                    "Proton-9.0",
+                    on_success=on_success,
+                )
+                assert result[0] is True
+                on_success.assert_called_once()
+
+    def test_calls_on_success_on_update_ok(self, umu_install_dir, fake_proton_path):
+        """on_success callback should be called on successful update."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        on_success = MagicMock()
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime(
+                    "Proton-9.0",
+                    on_success=on_success,
+                )
+                assert result[0] is True
+                on_success.assert_called_once()
+
+    def test_returns_failed_on_nonzero_exit(self, umu_install_dir, fake_proton_path):
+        """Should return (False, message) when umu-run exits with non-zero code."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Error occurred\n"])
+        mock_proc.wait.return_value = 1
+        mock_proc.returncode = 1
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime("Proton-9.0")
+                assert result[0] is False
+                assert "exit code 1" in result[1]
+
+    def test_returns_failed_on_subprocess_exception(self, umu_install_dir, fake_proton_path):
+        """Should return (False, str(e)) when subprocess.Popen raises an exception."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", side_effect=FileNotFoundError("bwrap not found")):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime("Proton-9.0")
+                assert result[0] is False
+                assert "bwrap not found" in result[1]
+
+    def test_returns_failed_when_no_stdout(self, umu_install_dir, fake_proton_path):
+        """Should return (False, 'No output from umu-run') when stdout is None."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = None
+        mock_proc.wait.return_value = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                result = update_steam_runtime("Proton-9.0")
+                assert result == (False, "No output from umu-run")
+
+    def test_sets_gameid_env(self, umu_install_dir, fake_proton_path):
+        """Should set GAMEID environment variable."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("Proton-9.0")
+
+                call_kwargs = subprocess.Popen.call_args[1]  # pyright: ignore[reportAttributeAccessIssue]
+                env = call_kwargs["env"]
+                assert env.get("GAMEID") == "umu-update-handshake"
+
+    def test_sets_protonpath_env(self, umu_install_dir, fake_proton_path):
+        """Should set PROTONPATH to the full path of the Proton directory."""
+        (fake_proton_path / "Proton-9.0").mkdir(parents=True, exist_ok=True)
+
+        mock_proc = MagicMock()
+        mock_proc.stdout = iter(["Done\n"])
+        mock_proc.wait.return_value = 0
+        mock_proc.returncode = 0
+
+        with patch("fungus.umu_manager.get_umu_run_path", return_value="/fake/umu-run"):
+            with patch("subprocess.Popen", return_value=mock_proc):
+                from fungus.umu_manager import update_steam_runtime
+
+                update_steam_runtime("Proton-9.0")
+
+                call_kwargs = subprocess.Popen.call_args[1]  # pyright: ignore[reportAttributeAccessIssue]
+                env = call_kwargs["env"]
+                assert env.get("PROTONPATH") == str(fake_proton_path / "Proton-9.0")
diff --git a/tests/test_utils_pure.py b/tests/test_utils_pure.py
new file mode 100644
index 0000000..d7f79f1
--- /dev/null
+++ b/tests/test_utils_pure.py
@@ -0,0 +1,396 @@
+"""Tests for pure utility functions not covered in test_utils.py.
+
+Covers:
+  - is_valid_prefix_path
+  - is_safe_prefix_path
+  - _resolve_runner_to_directory
+  - has_proton_installed
+"""
+
+from unittest.mock import patch
+
+
+# ── is_valid_prefix_path ──────────────────────────────────────────────────
+
+
+class TestIsValidPrefixPath:
+    """Tests for fungus.utils_pure.is_valid_prefix_path."""
+
+    def test_inside_prefixes_dir(self, tmp_path):
+        """Path inside the configured prefixes directory returns True."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        result = is_valid_prefix_path(str(prefixes / "umu-1234"), str(prefixes))
+        assert result is True
+
+    def test_is_prefixes_dir_itself(self, tmp_path):
+        """The prefixes directory itself is valid."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        result = is_valid_prefix_path(str(prefixes), str(prefixes))
+        assert result is True
+
+    def test_outside_prefixes_dir(self, tmp_path):
+        """Path outside the prefixes directory returns False."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        result = is_valid_prefix_path(
+            str(tmp_path / "other" / "stuff"), str(prefixes)
+        )
+        assert result is False
+
+    def test_parent_of_prefixes_dir(self, tmp_path):
+        """Parent directory of prefixes_dir is not valid."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        result = is_valid_prefix_path(str(tmp_path / "fungus"), str(prefixes))
+        assert result is False
+
+    def test_deeply_nested_path(self, tmp_path):
+        """Deeply nested paths inside prefixes_dir are valid."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        deep = prefixes / "a" / "b" / "c" / "d"
+        result = is_valid_prefix_path(str(deep), str(prefixes))
+        assert result is True
+
+    def test_similar_prefix_name_not_matched(self, tmp_path):
+        """A directory with a similar name but not under prefixes_dir is rejected."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        result = is_valid_prefix_path(
+            str(tmp_path / "fungus" / "prefixes_extra" / "game"), str(prefixes)
+        )
+        assert result is False
+
+    def test_expands_tilde(self, tmp_path, monkeypatch):
+        """Tilde in path is expanded before checking."""
+        from fungus.utils_pure import is_valid_prefix_path
+
+        prefixes = tmp_path / "fungus" / "prefixes"
+        prefixes.mkdir(parents=True)
+        # Set HOME so ~ expands to tmp_path
+        monkeypatch.setenv("HOME", str(tmp_path))
+        result = is_valid_prefix_path("~/fungus/prefixes/some-game", str(prefixes))
+        assert result is True
+
+
+# ── is_safe_prefix_path ───────────────────────────────────────────────────
+
+
+class TestIsSafePrefixPath:
+    """Tests for fungus.utils_pure.is_safe_prefix_path."""
+
+    def test_inside_user_data(self, tmp_path):
+        """Path inside user-data directory returns True."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_data.mkdir()
+        result = is_safe_prefix_path(
+            str(user_data / "fungus-launcher" / "games"),
+            user_data=str(user_data),
+        )
+        assert result is True
+
+    def test_inside_user_config(self, tmp_path):
+        """Path inside user-config directory returns True."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_config = tmp_path / "test_config"
+        user_config.mkdir()
+        result = is_safe_prefix_path(
+            str(user_config / "fungus-launcher" / "config.ini"),
+            user_config=str(user_config),
+        )
+        assert result is True
+
+    def test_is_user_data_root(self, tmp_path):
+        """The user-data root itself is safe."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_data.mkdir()
+        result = is_safe_prefix_path(str(user_data), user_data=str(user_data))
+        assert result is True
+
+    def test_is_user_config_root(self, tmp_path):
+        """The user-config root itself is safe."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_config = tmp_path / "test_config"
+        user_config.mkdir()
+        result = is_safe_prefix_path(
+            str(user_config), user_config=str(user_config)
+        )
+        assert result is True
+
+    def test_outside_both_safe_roots(self, tmp_path):
+        """Path outside both safe roots returns False."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_config = tmp_path / "test_config"
+        user_data.mkdir()
+        user_config.mkdir()
+        result = is_safe_prefix_path(
+            "/tmp/random/file.txt",
+            user_data=str(user_data),
+            user_config=str(user_config),
+        )
+        assert result is False
+
+    def test_parent_of_safe_roots(self, tmp_path):
+        """Parent of safe roots is not safe."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_config = tmp_path / "test_config"
+        user_data.mkdir()
+        user_config.mkdir()
+        # Parent of user_data is tmp_path itself
+        result = is_safe_prefix_path(
+            str(tmp_path),
+            user_data=str(user_data),
+            user_config=str(user_config),
+        )
+        assert result is False
+
+    def test_deeply_nested_safe_path(self, tmp_path):
+        """Deeply nested paths inside safe roots are valid."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_data.mkdir()
+        deep = user_data / "a" / "b" / "c"
+        result = is_safe_prefix_path(
+            str(deep), user_data=str(user_data)
+        )
+        assert result is True
+
+    def test_similar_name_not_matched(self, tmp_path):
+        """A path with a similar name but not under a safe root is rejected."""
+        from fungus.utils_pure import is_safe_prefix_path
+
+        user_data = tmp_path / "test_data"
+        user_data.mkdir()
+        # Sibling directory with a similar name
+        sibling = tmp_path / "test_data_extra"
+        result = is_safe_prefix_path(
+            str(sibling / "file"), user_data=str(user_data)
+        )
+        assert result is False
+
+
+# ── _resolve_runner_to_directory ──────────────────────────────────────────
+
+
+class TestResolveRunnerToDirectory:
+    """Tests for fungus.utils_pure._resolve_runner_to_directory."""
+
+    def _make_compat_tree(self, tmp_path, subdirs):
+        """Create a compatibilitytools.d directory tree."""
+        compat = tmp_path / "Steam" / "compatibilitytools.d"
+        compat.mkdir(parents=True)
+        for d in subdirs:
+            (compat / d).mkdir()
+        return compat
+
+    def test_direct_name_match(self, tmp_path):
+        """A runner name that matches a directory name passes through."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, ["GE-Proton11-1"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("GE-Proton11-1")
+        assert result == "GE-Proton11-1"
+
+    def test_alias_ge_proton_latest(self, tmp_path):
+        """'Proton-GE Latest' alias resolves to the newest GE-Proton directory."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, [
+            "GE-Proton9-11",
+            "GE-Proton10-1",
+            "GE-Proton11-1",
+        ])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("Proton-GE Latest")
+        assert result == "GE-Proton11-1"
+
+    def test_alias_ge_proton_latest_default(self, tmp_path):
+        """'GE-Proton Latest (default)' alias also resolves to newest."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, [
+            "GE-Proton8-22",
+            "GE-Proton10-5",
+        ])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("GE-Proton Latest (default)")
+        assert result == "GE-Proton10-5"
+
+    def test_alias_proton_em_latest(self, tmp_path):
+        """'Proton-EM Latest' alias resolves to newest Proton-EM."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, [
+            "Proton-EM-1.0",
+            "Proton-EM-2.0",
+        ])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("Proton-EM Latest")
+        assert result == "Proton-EM-2.0"
+
+    def test_alias_umu_proton_returns_none(self, tmp_path):
+        """'UMU-Proton Latest' has no directory equivalent → None."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, ["UMU-Proton-latest"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("UMU-Proton Latest")
+        assert result is None
+
+    def test_unknown_runner_returns_none(self, tmp_path):
+        """Unknown runner aliases return None."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, ["GE-Proton11-1"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("Linux-Native")
+        assert result is None
+
+    def test_no_compat_directory_returns_none(self, tmp_path):
+        """When compatibilitytools.d doesn't exist, returns None."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("GE-Proton11-1")
+        assert result is None
+
+    def test_no_matching_versions_returns_none(self, tmp_path):
+        """When no directories match the family, returns None."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, ["SomeOtherTool-1.0"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("Proton-GE Latest")
+        assert result is None
+
+    def test_newest_version_wins(self, tmp_path):
+        """Among matching versions, the newest one is returned."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, [
+            "GE-Proton7-27",
+            "GE-Proton9-24",
+            "GE-Proton10-7",
+        ])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("GE-Proton10-7")
+        assert result == "GE-Proton10-7"
+
+    def test_direct_name_not_a_dir_returns_none(self, tmp_path):
+        """If the runner name doesn't match any directory, returns None."""
+        from fungus.utils_pure import _resolve_runner_to_directory
+
+        self._make_compat_tree(tmp_path, ["GE-Proton11-1"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = _resolve_runner_to_directory("NonExistentRunner")
+        assert result is None
+
+
+# ── has_proton_installed ──────────────────────────────────────────────────
+
+
+class TestHasProtonInstalled:
+    """Tests for fungus.utils_pure.has_proton_installed."""
+
+    def _make_compat_tree(self, tmp_path, entries):
+        """Create a compatibilitytools.d directory tree with given entries."""
+        compat = tmp_path / "Steam" / "compatibilitytools.d"
+        compat.mkdir(parents=True)
+        for entry in entries:
+            if entry.endswith("/"):
+                (compat / entry.rstrip("/")).mkdir()
+            else:
+                (compat / entry).mkdir()
+        return compat
+
+    def test_no_compat_directory(self, tmp_path):
+        """When compatibilitytools.d doesn't exist, returns False."""
+        from fungus.utils_pure import has_proton_installed
+
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is False
+
+    def test_only_legacy_runtime(self, tmp_path):
+        """Only LegacyRuntime directory → no proton installed."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, ["LegacyRuntime/"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is False
+
+    def test_ge_proton_installed(self, tmp_path):
+        """GE-Proton directory → proton is installed."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, ["GE-Proton11-1/"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is True
+
+    def test_proton_em_installed(self, tmp_path):
+        """Proton-EM directory → proton is installed."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, ["Proton-EM-2.0/"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is True
+
+    def test_official_proton_installed(self, tmp_path):
+        """Official Proton directory → proton is installed."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, ["Proton-10.0-1/"])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is True
+
+    def test_mixed_entries(self, tmp_path):
+        """Mixed LegacyRuntime + actual proton → returns True."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, [
+            "LegacyRuntime/",
+            "GE-Proton9-11/",
+            "some-other-tool/",
+        ])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is True
+
+    def test_empty_directory(self, tmp_path):
+        """Empty compatibilitytools.d → returns False."""
+        from fungus.utils_pure import has_proton_installed
+
+        self._make_compat_tree(tmp_path, [])
+        with patch("fungus.constants.share_dir", str(tmp_path)):
+            result = has_proton_installed()
+        assert result is False