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

This commit is contained in:
aclist 2026-06-29 07:28:35 +09:00
parent 4de5147899
commit 2b87272b52
3 changed files with 32 additions and 17 deletions

View File

@ -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)

View File

@ -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),

View File

@ -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