# tests/test_config.py import toml from pathlib import Path from ctf.config import Config TEST_ENV = Path("tests/env") # {{{ test_load_config_static def test_load_config_static(): """Verifies Config loading using a persistent test file.""" config_file = TEST_ENV / "config.toml" test_data = { "Competition": {"name": "PersistentComp"}, "Enviroment": {"data_dir": str(TEST_ENV.absolute())} } config_file.parent.mkdir(parents=True, exist_ok=True) with open(config_file, "w") as f: toml.dump(test_data, f) cfg = Config(config_file) assert cfg.data["Competition"]["name"] == "PersistentComp" # }}} # {{{ test_write_config_static def test_write_config_static(): """Verifies Config writing by saving and reloading.""" config_file = TEST_ENV / "test_write_config.toml" test_data = {"TestKey": "TestVal"} cfg = Config(config_file) cfg.save(test_data) reloaded = Config(config_file) assert reloaded.data == test_data # }}}