"""Customer Mission #3 — one profile, three target TYPES (Requirements Verification proof).

Pins what Mission #3 proves with the real engines: the pipeline is target-type-agnostic (a regulation,
a certification and a contract all reduce to required capabilities and run through assess_transition),
and Evidence-Relevance is target-relative (the same certification is worth a different amount against a
different target — PSIRT is hoch against the CRA, keine against TISAX, mittel against the tender).
"""

from __future__ import annotations

import os
import subprocess
import sys


def _run():
    root = os.path.join(os.path.dirname(__file__), "..")
    r = subprocess.run(
        [sys.executable, "reference_scenarios/mission_three_target_types.py"],
        cwd=root, env={**os.environ, "PYTHONPATH": "."}, capture_output=True, text=True,
    )
    assert r.returncode == 0, r.stderr
    return r.stdout


def test_runs_end_to_end():
    out = _run()
    assert "Customer Mission #3" in out
    assert "ZIELTYP-AGNOSTISCH" in out


def test_three_target_types_one_engine():
    out = _run()
    # a regulation, a certification and a contract all rendered through the same engine
    for kind in ["Regulation", "Certification", "Contract"]:
        assert kind in out
    assert "Öffentliche Ausschreibung" in out


def test_evidence_relevance_is_target_relative():
    out = _run()
    # the headline demonstration: PSIRT ranks differently per target
    assert "**PSIRT** | hoch (3) | keine (0) | mittel (1) |" in out
    # ISO 14001 is irrelevant to all three security/quality targets (but noted hoch for environmental)
    assert "**ISO14001** | keine (0) | keine (0) | keine (0) |" in out
    assert "Relevanz ist eine Funktion des Ziels" in out


def test_cross_target_type_convergence():
    out = _run()
    assert "über Zieltypen hinweg" in out
    assert "Zielarten gleichzeitig" in out


def test_no_real_company_names():
    out = _run().lower()
    for name in ["eto", "owis", "winterhalter"]:
        assert name not in out
