36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from pyxray.config import CoreConfig, load_core_config
|
|
|
|
|
|
def test_core_config_defaults_are_empty() -> None:
|
|
config = CoreConfig()
|
|
|
|
assert config.xray.xray_url == ""
|
|
assert config.xray.geo_url == ""
|
|
assert config.xray.geoip_url == ""
|
|
assert config.xray.geosite_url == ""
|
|
assert config.xray.auto_update_interval == 0
|
|
assert config.download.proxy_url == ""
|
|
|
|
|
|
def test_load_core_config_creates_core_toml(tmp_path) -> None:
|
|
config, paths = load_core_config(tmp_path)
|
|
|
|
assert config.xray.auto_update_interval == 0
|
|
assert paths.config_file == tmp_path / "core.toml"
|
|
assert paths.config_file.exists()
|
|
assert paths.xray_dir.exists()
|
|
assert paths.temp_dir.exists()
|
|
assert "workdir" not in paths.config_file.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_load_core_config_removes_deprecated_workdir(tmp_path) -> None:
|
|
config_file = tmp_path / "core.toml"
|
|
config_file.write_text(
|
|
'workdir = "old"\n\n[download]\nproxy_url = ""\n\n[xray]\nxray_url = ""\n',
|
|
encoding="utf-8",
|
|
)
|
|
|
|
_, paths = load_core_config(tmp_path)
|
|
|
|
assert "workdir" not in paths.config_file.read_text(encoding="utf-8")
|