[GEMINI] Refactor test suite structure for new helpers and config modules

This commit is contained in:
venus
2026-07-19 00:53:00 -05:00
parent 8b82058cc6
commit 4bddd4a49b
6 changed files with 59 additions and 39 deletions

33
tests/test_config.py Normal file
View 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
# }}}