From 26d7799fe90e621994503231ac917336f99b6145 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 21 Oct 2026 10:12:29 +0200 Subject: sbb-remote 0.10.0: config-get/config-set; GUI watches its config Keystone's settings pages edit both configs. config-get returns the VM config text, the defaults and the path; config-set validates new text with the same check() as load_config, keeps .bak and replaces the file atomically. Both run before load_config, so a broken config can still be read and fixed. The GUI reloads its config when the file changes, re-adding the watch after an atomic write replaces the inode. Co-Authored-By: Claude Opus 5.5 --- tests/test_gui.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_gui.py') diff --git a/tests/test_gui.py b/tests/test_gui.py index 52e4ea7..c89dc86 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -628,6 +628,25 @@ class SmokeTest(unittest.TestCase): w.dashboard.jobs.clicked.emit() self.assertIs(w.tabs.currentWidget(), w.jobs_tab) + def test_config_file_watched(self): + tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, tmp) + old = os.environ.get("XDG_CONFIG_HOME") + os.environ["XDG_CONFIG_HOME"] = tmp + self.addCleanup(lambda: os.environ.__setitem__("XDG_CONFIG_HOME", old) if old + else os.environ.pop("XDG_CONFIG_HOME")) + os.makedirs(os.path.dirname(config.path())) + + def save(jobs): # an atomic write, as Keystone's settings page does: a new inode + with open(config.path() + ".tmp", "w") as f: + f.write(f"[refresh]\njobs = {jobs}\n") + os.replace(config.path() + ".tmp", config.path()) + save(5) + w, _remote = self.window() + for jobs in (7, 9): # the second one proves the path was watched again + save(jobs) + self.wait(lambda: w.cfg["refresh"]["jobs"] == jobs) + def wait(self, cond, secs=5): end = time.time() + secs while not cond() and time.time() < end: -- cgit v1.2.3