Tests: the Terminal fixtures write settings where the platform keeps them and no longer swap os.name or assume a Windows ACL on Linux (PR #3782 by BColsey)
This commit is contained in:
1 parent
24c3f24ae1
commit
19bfcb33f0
5 files changed
+22
-6
No files matched your search
@@ -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())
|
||||
|
||||
@@ -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"])
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in new issue
Block a user