41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SRC_DIR = ROOT / "src"
|
|
if str(SRC_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SRC_DIR))
|
|
|
|
import renunney.track1_api as api
|
|
|
|
|
|
def test_run_config_simulate_mode_returns_contract():
|
|
config = api.Track1RunConfig(mode="simulate", K=5000, N0=20, n=1, u=5e-6, R=10.0, T=20, seed=1)
|
|
payload = api.run_config(config)
|
|
assert payload["mode"] == "simulate"
|
|
assert payload["parameters"]["u"] == 5e-6
|
|
assert payload["parameters"]["M"] == 0.05
|
|
assert "final_summary" in payload
|
|
assert "tracking_summary" in payload
|
|
|
|
|
|
def test_config_roundtrip_from_mapping_and_file(tmp_path: Path):
|
|
raw = {
|
|
"mode": "search",
|
|
"K": 5000,
|
|
"N0": 20,
|
|
"n": 1,
|
|
"u": 5e-6,
|
|
"R": 10.0,
|
|
"T": 20,
|
|
"runs": 1,
|
|
"jobs": 1,
|
|
"t_values": [5, 10],
|
|
}
|
|
cfg = api.config_from_mapping(raw)
|
|
path = tmp_path / "track1.json"
|
|
path.write_text(json.dumps(raw), encoding="utf-8")
|
|
loaded = api.load_config(path)
|
|
assert loaded == cfg
|