From 2b87272b529cf8146e15be80fc89359ea57c194c Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Mon, 29 Jun 2026 07:28:35 +0900 Subject: [PATCH] chore: update test conditions --- dzgui/app_init.py | 20 +++++++++++++------- dzgui/views/dialogs/boot.py | 1 - tests/test_bare_conf_files.py | 28 +++++++++++++++++++--------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/dzgui/app_init.py b/dzgui/app_init.py index fc86e52..3ed89d2 100644 --- a/dzgui/app_init.py +++ b/dzgui/app_init.py @@ -70,18 +70,24 @@ def copy_bare_configs(config: "Path", resolution: "Path") -> tuple[bool, bool]: new_file = config old_file = config.parent.parent / conf if old_file.is_file(): - make_parents(new_file) - shutil.copy(old_file, new_file) - config_changed = True + try: + make_parents(new_file) + shutil.copy(old_file, new_file) + config_changed = True + except Exception as e: + logger.critical(e) if resolution.parent.exists() is False: state_path = resolution.parent for state_file in state: old_file = state_path.parent / state_file if old_file.is_file(): - new_file = state_path / state_file - make_parents(new_file) - shutil.copy(old_file, new_file) - state_changed = True + try: + new_file = state_path / state_file + make_parents(new_file) + shutil.copy(old_file, new_file) + state_changed = True + except Exception as e: + logger.critical(e) return (config_changed, state_changed) diff --git a/dzgui/views/dialogs/boot.py b/dzgui/views/dialogs/boot.py index f2b275d..8491530 100644 --- a/dzgui/views/dialogs/boot.py +++ b/dzgui/views/dialogs/boot.py @@ -121,7 +121,6 @@ class BootDialog(Gtk.Dialog): self.error_box.hide() - print(self.xdg.ips) steps = [ (StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False), (StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False), diff --git a/tests/test_bare_conf_files.py b/tests/test_bare_conf_files.py index 8153e05..9235390 100644 --- a/tests/test_bare_conf_files.py +++ b/tests/test_bare_conf_files.py @@ -10,6 +10,7 @@ from pathlib import Path CONF_STRING = "DZGUI_CONF\n" STATE_STRING = "DZGUI_STATE\n" + @pytest.fixture def state_files(): state = [ @@ -28,7 +29,12 @@ def state_files(): @pytest.fixture def xdg_paths(): paths = [] - routes = {"XDG_CONFIG_HOME": "", "XDG_STATE_HOME": "", "XDG_DATA_HOME": "", "XDG_CACHE_HOME": ""} + routes = { + "XDG_CONFIG_HOME": "", + "XDG_STATE_HOME": "", + "XDG_DATA_HOME": "", + "XDG_CACHE_HOME": "", + } for route in routes: tmp = tempfile.TemporaryDirectory(delete=False) routes[route] = tmp.name @@ -37,23 +43,27 @@ def xdg_paths(): env = get_xdg_paths() return parse_filepaths(env) + @pytest.mark.mods def test_config_file_import(xdg_paths, state_files): + # NOTE: write bare files in root tmp_conf = xdg_paths.config.parent.parent tmp_conf_file = tmp_conf / xdg_paths.config.name tmp_conf_file.write_text(CONF_STRING) tmp_state = xdg_paths.resolution.parent.parent - tmp_state_file = tmp_state / xdg_paths.resolution.name - for file in state_files: tmp_state.joinpath(file).write_text(STATE_STRING) - config_changed, state_changed = copy_bare_configs(xdg_paths.config, xdg_paths.resolution) + # NOTE: function should move files into "dzgui" subdirectory + config_changed, state_changed = copy_bare_configs( + xdg_paths.config, xdg_paths.resolution + ) - assert (tmp_conf / xdg_paths.config.name).read_text() == CONF_STRING + assert xdg_paths.config.read_text() == CONF_STRING for file in state_files: - assert (tmp_state / file).read_text() == STATE_STRING + expected = xdg_paths.resolution.parent.joinpath(file) + assert expected.read_text() == STATE_STRING assert config_changed is True assert state_changed is True @@ -67,11 +77,11 @@ def test_config_file_no_import(xdg_paths, state_files): tmp_conf_file = xdg_paths.config tmp_conf_file.write_text(CONF_STRING) - tmp_state_file = xdg_paths.resolution - for file in state_files: xdg_paths.resolution.parent.joinpath(file).write_text(STATE_STRING) - config_changed, state_changed = copy_bare_configs(xdg_paths.config, xdg_paths.resolution) + config_changed, state_changed = copy_bare_configs( + xdg_paths.config, xdg_paths.resolution + ) assert config_changed is False assert state_changed is False