#!/usr/bin/env python3
import json, sys
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO / "scripts"))
from qubo_solve import solve_qubo_dwave, solve_qubo_ibm

def _toy_qubo(n=6):
    # simple two-hot-ish toy
    lin = {str(i): 0.0 for i in range(n)}
    quad = {f"{i},{j}": -1.0 for i in range(n) for j in range(i+1, n)}
    return {"n": n, "linear": lin, "quadratic": quad}

def test_paths_distinct():
    q = _toy_qubo(6)
    a = solve_qubo_dwave(q, seed=0, sweeps=200, num_reads=1)
    b = solve_qubo_ibm(q, seed=0, reps=1, num_reads=1)
    assert a["sampler"] != b["sampler"], f"D-Wave and IBM should use different samplers: {a['sampler']} vs {b['sampler']}"
    assert "metrics" in a and "metrics" in b
    assert "proxies" in a and "proxies" in b
    assert "certificate" in a and "certificate" in b
    print(f"✅ Backend dispatch test passed")
    print(f"   D-Wave sampler: {a['sampler']}")
    print(f"   IBM sampler: {b['sampler']}")
    print(f"   Both have metrics, proxies, and certificates")

if __name__ == "__main__":
    test_paths_distinct()
