chore: add test for no import case

This commit is contained in:
aclist committed 2026-06-28 00:07:51 +09:00
1 parent 61f90d6016
commit 4c31cd7ecd
2 files changed
+47 -11

No files matched your search

+38 -7
View File
@@ -4,10 +4,8 @@ import tempfile
from dzgui.app_init import copy_bare_configs
from pathlib import Path
@pytest.mark.mods
def test_bare_file_import():
conf_string = "DZGUI_CONF\n"
state_string = "DZGUI_STATE\n"
@pytest.fixture
def state_files():
state = [
"dzg.history",
"dzg.versions",
@@ -18,6 +16,12 @@ def test_bare_file_import():
"ips.csv",
".month"
]
return state
@pytest.mark.mods
def test_config_file_import(state_files):
conf_string = "DZGUI_CONF\n"
state_string = "DZGUI_STATE\n"
tmp = tempfile.TemporaryDirectory()
tmp2 = tempfile.TemporaryDirectory()
@@ -26,12 +30,39 @@ def test_bare_file_import():
tmp_conf_file = tmp_conf / "config.json"
tmp_conf_file.write_text(conf_string)
for file in state:
for file in state_files:
tmp_state.joinpath(file).write_text(state_string)
tmp_state_file = tmp_state / "dzg.res.json"
copy_bare_configs(tmp_conf_file, tmp_state_file)
config_changed, state_changed = copy_bare_configs(tmp_conf_file, tmp_state_file)
assert (tmp_conf / "dzgui/config.json").read_text() == conf_string
for file in state:
for file in state_files:
assert (tmp_state / "dzgui" / file).read_text() == state_string
assert config_changed is True
assert state_changed is True
@pytest.mark.mods
def test_config_file_no_import(state_files):
conf_string = "DZGUI_CONF\n"
state_string = "DZGUI_STATE\n"
tmp = tempfile.TemporaryDirectory()
tmp2 = tempfile.TemporaryDirectory()
tmp_conf = Path(tmp.name)
tmp_state = Path(tmp2.name)
for d in tmp_conf, tmp_state:
subdir = d / "dzgui"
subdir.mkdir()
tmp_conf_file = tmp_conf / "dzgui/config.json"
tmp_conf_file.write_text(conf_string)
for file in state_files:
tmp_state.joinpath("dzgui").joinpath(file).write_text(state_string)
tmp_state_file = tmp_state / "dzgui/dzg.res.json"
config_changed, state_changed = copy_bare_configs(tmp_conf_file, tmp_state_file)
assert config_changed is False
assert state_changed is False