Adds the pydantic-settings Settings with validated GITEA_URL, OAuth scopes and toolsets, the argparse CLI skeleton, catalog.model, identity and GiteaAPIError. Test fixtures now isolate env, cwd and state paths in tmp.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Tests for the command line skeleton."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from aegis_gitea_mcp import __version__
|
|
from aegis_gitea_mcp.cli import build_parser, main
|
|
|
|
|
|
def test_version_prints_package_version(capsys: pytest.CaptureFixture[str]) -> None:
|
|
assert main(["version"]) == 0
|
|
assert capsys.readouterr().out.strip() == __version__
|
|
|
|
|
|
@pytest.mark.parametrize("argv", [[], ["serve"], ["serve", "--transport", "http"], ["setup"]])
|
|
def test_unbuilt_commands_exit_2(argv: list[str], capsys: pytest.CaptureFixture[str]) -> None:
|
|
assert main(argv) == 2
|
|
captured = capsys.readouterr()
|
|
assert "not implemented yet" in captured.err
|
|
assert captured.out == ""
|
|
|
|
|
|
def test_serve_transport_choices() -> None:
|
|
parser = build_parser()
|
|
assert parser.parse_args(["serve", "--transport", "stdio"]).transport == "stdio"
|
|
with pytest.raises(SystemExit):
|
|
parser.parse_args(["serve", "--transport", "sse"])
|
|
|
|
|
|
def test_package_version_matches_pyproject() -> None:
|
|
tomllib = pytest.importorskip("tomllib") # Python 3.11+
|
|
|
|
data = tomllib.loads((Path(__file__).parent.parent / "pyproject.toml").read_text())
|
|
assert data["project"]["version"] == __version__
|