"""Pytest wrapper around tools/verify_tier3_local.py.

The verifier is its own CLI for operators. The test wrapper just runs
the steps that are deterministic without external services so a
regression (e.g. someone breaking chunked_real_binary_upload) gets
caught by `pytest` without needing msfrpcd or a populated store.
"""

from __future__ import annotations

import importlib.util
import sys
from pathlib import Path


REPO_ROOT = Path(__file__).resolve().parent.parent
spec = importlib.util.spec_from_file_location(
    "verify_tier3_local", REPO_ROOT / "tools" / "verify_tier3_local.py"
)
v = importlib.util.module_from_spec(spec)
sys.modules["verify_tier3_local"] = v
spec.loader.exec_module(v)


def test_module_configs_parse() -> None:
    s = v.step_module_configs_parse()
    assert s.outcome == "PASS", f"{s.name}: {s.detail}"


def test_manifest_distribution() -> None:
    s = v.step_manifest_distribution()
    assert s.outcome == "PASS", f"{s.name}: {s.detail}"


def test_chunked_upload_through_real_sh(tmp_path) -> None:
    """The big one: chunked_real_binary_upload must survive a real
    /bin/sh round-trip. This is what proves the Tier-4 binary upload
    path will work against an msfrpc shell session — same wire shape,
    same shell semantics."""
    s = v.step_chunked_upload_via_local_sh(tmp_path)
    assert s.outcome == "PASS", f"{s.name}: {s.detail}"
