aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_gui.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_gui.py')
-rw-r--r--tests/test_gui.py19
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: