"""CF-01~07: Config + MappingConfig""" import sys, os, tempfile, json from pathlib import Path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) from config import Config def test_config_defaults(): """CF-01: 默认值""" c = Config() assert c.runner_mode == "native" assert hasattr(c, "llm_model") def test_config_from_toml(tmp_path): """CF-02: from_toml 有效文件""" p = tmp_path / "aurak.toml" p.write_text('[runner]\nmode = "spark"\n[llm]\nmodel = "gpt-4"\n') c = Config.from_toml(str(p)) assert c.runner_mode == "spark" assert c.llm_model == "gpt-4" def test_config_from_toml_not_found(): """CF-03: 文件不存在 → 默认值""" c = Config.from_toml("/nonexistent/aurak.toml") assert c.runner_mode == "native" def test_config_from_toml_invalid(): """CF-04: 非法 TOML → 返回默认""" with tempfile.TemporaryDirectory() as tmp: p = Path(tmp) / "bad.toml" p.write_text("= invalid toml [[[") c = Config.from_toml(str(p)) assert c is not None