"""Tests for the vmcluster-mcp console script entry point (INST-01)."""

import tomllib
from pathlib import Path

import pytest


def test_main_is_callable():
    """main() must be a callable so [project.scripts] shim works after install."""
    from vmcluster_mcp.__main__ import main  # noqa: PLC0415

    assert callable(main), "vmcluster_mcp.__main__.main must be a callable function"


def test_project_scripts_entry_exists():
    """[project.scripts] must map vmcluster-mcp to vmcluster_mcp.__main__:main."""
    pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
    with open(pyproject_path, "rb") as f:
        data = tomllib.load(f)

    scripts = data.get("project", {}).get("scripts", {})
    assert "vmcluster-mcp" in scripts, "[project.scripts] must contain 'vmcluster-mcp' key"
    assert scripts["vmcluster-mcp"] == "vmcluster_mcp.__main__:main", (
        "Entry point must be 'vmcluster_mcp.__main__:main'"
    )
