from __future__ import annotations

import json
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

import tools.validate_qualitative_sell_strategy_pipeline_v1 as validator


def test_validate_qualitative_sell_strategy_pipeline_passes(tmp_path, monkeypatch):
    out = tmp_path / "qualitative_sell_strategy_pipeline_v1.json"
    monkeypatch.setattr(sys, "argv", ["validate_qualitative_sell_strategy_pipeline_v1.py"])
    monkeypatch.setattr(validator, "ROOT", ROOT)

    rc = validator.main()
    payload = json.loads((ROOT / "Temp" / "qualitative_sell_strategy_pipeline_v1.json").read_text(encoding="utf-8"))

    assert rc == 0
    assert payload["gate"] == "PASS"
    assert payload["checks"]["store_contract"] is True
