diff --git a/tests/terminal/test_discovery.py b/tests/terminal/test_discovery.py index 98cd13c3..05e0b318 100644 --- a/tests/terminal/test_discovery.py +++ b/tests/terminal/test_discovery.py @@ -65,6 +65,8 @@ class GuiLayout(unittest.TestCase): self.env = {"LOCALAPPDATA": str(base / "local"), "XDG_DATA_HOME": str(base / "local"), "APPDATA": str(base / "roaming"), "XDG_CONFIG_HOME": str(base / "config"), "USERPROFILE": str(base / "home"), "HOME": str(base / "home"), "XDG_STATE_HOME": str(base / "state"), "XDG_DOCUMENTS_DIR": ""} + settings = Path(self.env["APPDATA"]) / "Strata" if os.name == "nt" else Path(self.env["XDG_CONFIG_HOME"]) / "strata" + self.settings_path = settings / "settings.json" patch = mock.patch.dict(os.environ, self.env) patch.start() self.addCleanup(patch.stop) @@ -142,7 +144,7 @@ class GuiLayout(unittest.TestCase): old = self.base / "T-Strata" old.mkdir() (old / "strata-qwen-iq3_xxs.json").write_text(json.dumps({"exe": "e", "tokenizer": "t", "args": []})) - settings = Path(os.environ["APPDATA"]) / "Strata" / "settings.json" + settings = self.settings_path settings.parent.mkdir(parents=True) settings.write_text(json.dumps({"installs": [str(old)]})) got = models.list_installed() @@ -155,7 +157,7 @@ class GuiLayout(unittest.TestCase): (old / "strata-x.json").write_text(json.dumps({"exe": "e", "tokenizer": "t", "args": []})) app_settings = self.install.parent / "app-settings.json" with mock.patch.dict(os.environ, {"STRATA_SETTINGS_FILE": str(app_settings)}): - settings = Path(os.environ["APPDATA"]) / "Strata" / "settings.json" + settings = self.settings_path settings.parent.mkdir(parents=True) settings.write_text(json.dumps({"installs": [str(old)]})) self.assertEqual([m["id"] for m in models.list_installed()["models"]], ["gyro-gyro-s"]) @@ -258,7 +260,7 @@ class GuiLayout(unittest.TestCase): def test_an_own_setting_beats_the_apps_folder(self): mine = self.base / "mine" mine.mkdir() - settings = Path(os.environ["APPDATA"]) / "Strata" / "settings.json" + settings = self.settings_path settings.parent.mkdir(parents=True, exist_ok=True) settings.write_text(json.dumps({"data_dir": str(mine)})) self.assertEqual(self.catalog().data_dir().resolve(), mine.resolve()) diff --git a/tests/terminal/test_gfx_selection.py b/tests/terminal/test_gfx_selection.py index e02ef41f..b2e56ea9 100644 --- a/tests/terminal/test_gfx_selection.py +++ b/tests/terminal/test_gfx_selection.py @@ -3,6 +3,7 @@ build, 0.1.46.1) then won over the rx9070 one (0.1.46). Selection must follow th from __future__ import annotations import unittest +from types import SimpleNamespace from unittest import mock from strata_control import engine_component as ec, feed as feedmod, updater @@ -80,7 +81,11 @@ class Names(unittest.TestCase): class Detection(unittest.TestCase): def test_windows_without_hipinfo_reads_the_gfx_from_the_adapters(self): adapters = [{"vendor": "1002", "device": 0x7550, "name": "AMD Radeon RX 9070 XT", "vram_gb": 16.0}] - with mock.patch.object(updater.os, "name", "nt"), mock.patch.object(updater.shutil, "which", return_value=None), \ + # Keep pathlib on the host platform while both hardware probes model Windows. + windows = SimpleNamespace(name="nt") + with mock.patch.object(updater, "os", windows), mock.patch.object(ec, "os", windows), \ + mock.patch.object(updater, "Path", return_value=SimpleNamespace(is_dir=lambda: False)), \ + mock.patch.object(updater.shutil, "which", return_value=None), \ mock.patch.object(ec, "windows_display_adapters", return_value=adapters): self.assertEqual(updater._gfx_names(), ["gfx1201"]) self.assertEqual(updater._amd_card_names(), ["AMD Radeon RX 9070 XT"]) diff --git a/tests/terminal/test_launch_tui.py b/tests/terminal/test_launch_tui.py index dff55798..4aaf5eb7 100644 --- a/tests/terminal/test_launch_tui.py +++ b/tests/terminal/test_launch_tui.py @@ -699,7 +699,7 @@ class AccessStep(Base): await press(pilot, *self.reach(), "down", "down") t = text_of(app) self.assertIn("cloudflared is not installed on this computer", t) - self.assertIn("quick tunnel", t) + self.assertIn("quick tunnel", flat(app)) await press(pilot, "enter") self.assertEqual(ctx.settings.access, "cloudflare") self.assertIn("Save as preset, then launch", text_of(app)) diff --git a/tests/terminal/test_private_files.py b/tests/terminal/test_private_files.py index e6ce1b36..adfc64b3 100644 --- a/tests/terminal/test_private_files.py +++ b/tests/terminal/test_private_files.py @@ -77,9 +77,18 @@ class PrivateFileTests(unittest.TestCase): def test_a_file_made_in_the_profile_is_unshared_but_not_strictly_private(self): path = self.root / "inherited.json" path.write_text("{}") + if not pf.WINDOWS: + # POSIX files have mode bits rather than an inherited profile ACL. + # Specify the private mode instead of depending on the process umask. + path.chmod(0o600) self.assertTrue(pf.is_unshared(path)) if pf.WINDOWS: self.assertFalse(pf.is_private(path)) # SYSTEM and Administrators still inherit + else: + self.assertTrue(pf.is_private(path)) + path.chmod(0o644) + self.assertFalse(pf.is_unshared(path)) + self.assertFalse(pf.is_private(path)) @unittest.skipUnless(pf.WINDOWS, "NTFS ACLs") def test_everyone_is_noticed_by_the_relaxed_check_too(self): diff --git a/tests/terminal/test_shared_models_folder.py b/tests/terminal/test_shared_models_folder.py index 069c019f..c6357619 100644 --- a/tests/terminal/test_shared_models_folder.py +++ b/tests/terminal/test_shared_models_folder.py @@ -13,7 +13,7 @@ from tests.terminal.test_discovery import GuiLayout class SharedModelsFolder(GuiLayout): def files(self): - mine = Path(os.environ["APPDATA"]) / "Strata" / "settings.json" + mine = self.settings_path mine.parent.mkdir(parents=True, exist_ok=True) return mine, discovery.app_settings_file()