chore: update test conditions
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled

This commit is contained in:
aclist committed 2026-06-29 07:28:35 +09:00
1 parent 4de5147899
commit 2b87272b52
3 files changed
+25 -10

No files matched your search

+6
View File
@@ -70,18 +70,24 @@ def copy_bare_configs(config: "Path", resolution: "Path") -> tuple[bool, bool]:
new_file = config new_file = config
old_file = config.parent.parent / conf old_file = config.parent.parent / conf
if old_file.is_file(): if old_file.is_file():
try:
make_parents(new_file) make_parents(new_file)
shutil.copy(old_file, new_file) shutil.copy(old_file, new_file)
config_changed = True config_changed = True
except Exception as e:
logger.critical(e)
if resolution.parent.exists() is False: if resolution.parent.exists() is False:
state_path = resolution.parent state_path = resolution.parent
for state_file in state: for state_file in state:
old_file = state_path.parent / state_file old_file = state_path.parent / state_file
if old_file.is_file(): if old_file.is_file():
try:
new_file = state_path / state_file new_file = state_path / state_file
make_parents(new_file) make_parents(new_file)
shutil.copy(old_file, new_file) shutil.copy(old_file, new_file)
state_changed = True state_changed = True
except Exception as e:
logger.critical(e)
return (config_changed, state_changed) return (config_changed, state_changed)
-1
View File
@@ -121,7 +121,6 @@ class BootDialog(Gtk.Dialog):
self.error_box.hide() self.error_box.hide()
print(self.xdg.ips)
steps = [ steps = [
(StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False), (StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False),
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False), (StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
+19 -9
View File
@@ -10,6 +10,7 @@ from pathlib import Path
CONF_STRING = "DZGUI_CONF\n" CONF_STRING = "DZGUI_CONF\n"
STATE_STRING = "DZGUI_STATE\n" STATE_STRING = "DZGUI_STATE\n"
@pytest.fixture @pytest.fixture
def state_files(): def state_files():
state = [ state = [
@@ -28,7 +29,12 @@ def state_files():
@pytest.fixture @pytest.fixture
def xdg_paths(): def xdg_paths():
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: for route in routes:
tmp = tempfile.TemporaryDirectory(delete=False) tmp = tempfile.TemporaryDirectory(delete=False)
routes[route] = tmp.name routes[route] = tmp.name
@@ -37,23 +43,27 @@ def xdg_paths():
env = get_xdg_paths() env = get_xdg_paths()
return parse_filepaths(env) return parse_filepaths(env)
@pytest.mark.mods @pytest.mark.mods
def test_config_file_import(xdg_paths, state_files): def test_config_file_import(xdg_paths, state_files):
# NOTE: write bare files in root
tmp_conf = xdg_paths.config.parent.parent tmp_conf = xdg_paths.config.parent.parent
tmp_conf_file = tmp_conf / xdg_paths.config.name tmp_conf_file = tmp_conf / xdg_paths.config.name
tmp_conf_file.write_text(CONF_STRING) tmp_conf_file.write_text(CONF_STRING)
tmp_state = xdg_paths.resolution.parent.parent tmp_state = xdg_paths.resolution.parent.parent
tmp_state_file = tmp_state / xdg_paths.resolution.name
for file in state_files: for file in state_files:
tmp_state.joinpath(file).write_text(STATE_STRING) 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: 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 config_changed is True
assert state_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 = xdg_paths.config
tmp_conf_file.write_text(CONF_STRING) tmp_conf_file.write_text(CONF_STRING)
tmp_state_file = xdg_paths.resolution
for file in state_files: for file in state_files:
xdg_paths.resolution.parent.joinpath(file).write_text(STATE_STRING) 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 config_changed is False
assert state_changed is False assert state_changed is False