"""Cross-platform smoke tests for parser-level reliability contracts."""

from model_osmosis.cli import build_parser


def test_pipeline_smoke_contract_defaults():
    parser = build_parser()
    parsed = parser.parse_args(
        [
            "pipeline",
            "--mode",
            "merge",
            "--output-type",
            "osmoimg",
            "--models",
            "pt:a.pt",
            "pt:b.pt",
        ]
    )
    assert parsed.mode == "merge"
    assert parsed.output_type == "osmoimg"
    assert parsed.self_check is True
    assert parsed.self_check_level == "smoke"
    assert parsed.strategy_engine == "auto"


def test_pipeline_weight_merge_contract_defaults():
    parser = build_parser()
    parsed = parser.parse_args(
        [
            "pipeline",
            "--mode",
            "weight-merge",
            "--output-type",
            "pytorch",
            "--models",
            "pt:a.pt",
            "pt:b.pt",
        ]
    )
    assert parsed.mode == "weight-merge"
    assert parsed.output_type == "pytorch"
    assert parsed.coverage_floor == 0.70
    assert parsed.self_check_level == "smoke"
    assert parsed.strategy_engine == "auto"


def test_pipeline_smoke_contract_explicit_levels():
    parser = build_parser()
    parsed = parser.parse_args(
        [
            "pipeline",
            "--mode",
            "merge",
            "--output-type",
            "pytorch",
            "--models",
            "pt:a.pt",
            "pt:b.pt",
            "--self-check-level",
            "parity",
        ]
    )
    assert parsed.self_check is True
    assert parsed.self_check_level == "parity"

    parsed_off = parser.parse_args(
        [
            "pipeline",
            "--mode",
            "merge",
            "--output-type",
            "pytorch",
            "--models",
            "pt:a.pt",
            "pt:b.pt",
            "--no-self-check",
        ]
    )
    assert parsed_off.self_check is False
    assert parsed_off.self_check_level == "smoke"


def test_run_export_serve_support_trust_profile_and_release_check_parser():
    parser = build_parser()
    parsed_run = parser.parse_args(
        ["run", "model.osmoimg", "--prompt", "hi", "--trust-profile", "production"]
    )
    assert parsed_run.trust_profile == "production"

    parsed_export = parser.parse_args(
        ["export", "model.osmoimg", "--format", "pytorch", "--trust-profile", "standard"]
    )
    assert parsed_export.trust_profile == "standard"

    parsed_serve = parser.parse_args(
        ["serve", "model.osmoimg", "--trust-profile", "production"]
    )
    assert parsed_serve.trust_profile == "production"

    parsed_release = parser.parse_args(["release-check", "--with-ci", "--strict-ci", "--json"])
    assert parsed_release.with_ci is True
    assert parsed_release.strict_ci is True
    assert parsed_release.json is True

    parsed_local = parser.parse_args(["release-check", "--local-only"])
    assert parsed_local.local_only is True
