[GEMINI] Refactor test suite structure for new helpers and config modules
This commit is contained in:
33
tests/test_config.py
Normal file
33
tests/test_config.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# tests/test_config.py
|
||||
import toml
|
||||
from pathlib import Path
|
||||
from ctf.config import load_config, write_config
|
||||
|
||||
TEST_ENV = Path("tests/env")
|
||||
|
||||
# {{{ test_load_config_static
|
||||
def test_load_config_static():
|
||||
"""Verifies load_config using the 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)
|
||||
|
||||
loaded_data = load_config(str(config_file))
|
||||
assert loaded_data["Competition"]["name"] == "PersistentComp"
|
||||
# }}}
|
||||
|
||||
# {{{ test_write_config_static
|
||||
def test_write_config_static():
|
||||
"""Verifies write_config by writing and reloading."""
|
||||
config_file = TEST_ENV / "test_write_config.toml"
|
||||
test_data = {"TestKey": "TestVal"}
|
||||
|
||||
write_config(test_data, str(config_file))
|
||||
loaded = load_config(str(config_file))
|
||||
assert loaded == test_data
|
||||
# }}}
|
||||
Reference in New Issue
Block a user