29 lines
972 B
Python
29 lines
972 B
Python
"""Smoke tests for config loader (src/config.py). Needs python-dotenv only."""
|
|
|
|
from src.config import load_config
|
|
|
|
_KEYS = [
|
|
"LOCAL_RTSP", "JETSON_RTSP", "MODEL_SACK_PATH", "MODEL_TRUCK_PATH",
|
|
"COUNTING_LINE_Y", "COUNTING_LINE_X_START", "COUNTING_LINE_X_END",
|
|
"SACK_CONF_THRESHOLD", "TRUCK_CONF_THRESHOLD", "BATCH_TIMEOUT_SECONDS",
|
|
"CSV_OUTPUT_DIR", "DATA_SEED",
|
|
]
|
|
|
|
|
|
def test_load_from_env_file(tmp_path, monkeypatch):
|
|
for k in _KEYS:
|
|
monkeypatch.delenv(k, raising=False)
|
|
env = tmp_path / "test.env"
|
|
env.write_text(
|
|
"LOCAL_RTSP=rtsp://cam/1\n"
|
|
"MODEL_SACK_PATH=/m/sack.pt\n"
|
|
"MODEL_TRUCK_PATH=/m/truck.pt\n"
|
|
"SACK_CONF_THRESHOLD=0.55\n"
|
|
)
|
|
cfg = load_config(str(env))
|
|
assert cfg.local_rtsp == "rtsp://cam/1"
|
|
assert cfg.sack_model_path == "/m/sack.pt"
|
|
assert cfg.truck_model_path == "/m/truck.pt"
|
|
assert cfg.sack_conf == 0.55
|
|
assert cfg.truck_conf == 0.50 # default preserved
|