mirror of
https://git.hiabuto.net/C3MA/CCMA.git
synced 2026-07-01 11:14:52 +02:00
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import json
|
|
|
|
from ccma.config import AppConfig, load_config
|
|
|
|
|
|
def test_paths_and_automation_settings_round_trip(tmp_path, monkeypatch) -> None:
|
|
monkeypatch.setenv("CCMA_CONFIG_DIR", str(tmp_path / "config"))
|
|
expected = AppConfig(
|
|
store_path=str(tmp_path / "members"),
|
|
gnucash_path=str(tmp_path / "club.gnucash"),
|
|
theme_mode="light",
|
|
run_housekeeper_on_startup=False,
|
|
birthday_days_before=10,
|
|
birthday_days_after=3,
|
|
anniversary_days_before=21,
|
|
anniversary_days_after=5,
|
|
anniversary_intervals="30D;2M;1Y;10Y",
|
|
window_geometry="1200x800-1800+40",
|
|
window_state="maximized",
|
|
monitor_bounds=(-1920, 0, 1920, 1080),
|
|
)
|
|
expected.save()
|
|
|
|
loaded = load_config()
|
|
assert loaded == expected
|
|
raw = json.loads(expected.path.read_text(encoding="utf-8"))
|
|
assert raw["schema_version"] == 1
|
|
assert raw["monitor_bounds"] == [-1920, 0, 1920, 1080]
|
|
|
|
|
|
def test_legacy_c3ma_environment_variables_are_still_read(tmp_path, monkeypatch) -> None:
|
|
monkeypatch.delenv("CCMA_CONFIG_DIR", raising=False)
|
|
monkeypatch.delenv("CCMA_STORE", raising=False)
|
|
monkeypatch.setenv("C3MA_CONFIG_DIR", str(tmp_path / "legacy-config"))
|
|
monkeypatch.setenv("C3MA_STORE", str(tmp_path / "legacy-store"))
|
|
|
|
assert load_config().store_path == str(tmp_path / "legacy-store")
|