from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def test_qwen3_is_active_runtime_model_not_unused_ollama_weight():
    openclaw_source = (ROOT / "services" / "openclaw_strategist_service.py").read_text(encoding="utf-8")
    nemotron_source = (ROOT / "services" / "nemoton_dispatcher_service.py").read_text(encoding="utf-8")
    router_source = (ROOT / "services" / "llm_model_router.py").read_text(encoding="utf-8")

    assert "OPENCLAW_QA_OLLAMA_MODEL = os.getenv('OPENCLAW_QA_OLLAMA_MODEL', 'qwen3:14b')" in openclaw_source
    assert "def _call_qwen3_qa(" in openclaw_source
    assert "OllamaService(model=OPENCLAW_QA_OLLAMA_MODEL)" in openclaw_source
    assert "OPENCLAW_QA_OLLAMA_HOST" not in openclaw_source
    assert "OPENCLAW_STRATEGY_OLLAMA_KEEP_ALIVE = os.getenv('OPENCLAW_STRATEGY_OLLAMA_KEEP_ALIVE', '5m')" in openclaw_source
    assert "keep_alive=OPENCLAW_STRATEGY_OLLAMA_KEEP_ALIVE" in openclaw_source
    assert 'keep_alive="24h"' not in openclaw_source
    assert 'NEMOTRON_OLLAMA_MODEL = os.getenv("NEMOTRON_OLLAMA_MODEL", "qwen3:14b")' in nemotron_source
    assert "def _call_qwen3_dispatch(" in nemotron_source
    assert "for _attempt in range(3):" in nemotron_source
    assert "'qwen3:14b'" in router_source
