diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-21 10:12:29 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-21 10:12:29 +0200 |
| commit | 26d7799fe90e621994503231ac917336f99b6145 (patch) | |
| tree | 286306f6f9bd74e9e1090f7927e9efd343d2df01 /tests/test_gui.py | |
| parent | 1c1fb069f7f3bae5946c485ef48846c150ef1d54 (diff) | |
| download | sb-builder-26d7799fe90e621994503231ac917336f99b6145.tar.gz sb-builder-26d7799fe90e621994503231ac917336f99b6145.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_gui.py')
| -rw-r--r-- | tests/test_gui.py | 19 |
1 files changed, 19 insertions, 0 deletions
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: |
