Files
freecad-robust-mcp-fc111/tests/just_commands/test_mcp.py
T
Sean P. KaneandGitHub f14ab8177d Fix: rename workbench and prepare for release (#27)
* chore: rename workbench to FreecadRobustMCPBridge

* fix: stdio cleanup and bug fix for JSON RPC

* fix: update FreeCAD MCP bridge and tests

* test: Fix GUI Integration tests and other issues

* fix: unit tests in CI and a few other things

* docs: generate GitHub pages site and link to it.

* fix: General code improvements and DRY refactoring

* chore: General cleanup

* chore: small fixes

* docs: cleanup

* docs: fixes

* docs: small corrections

* docs: fix

* test: release check

* bump: workbench v0.6.0

* chore: bump macros to 0.6.0

* docs: Release improvements

* refactor: improve DRYness of code
2026-01-12 09:30:05 -08:00

60 lines
1.9 KiB
Python

"""Tests for mcp module just commands.
These tests verify that MCP server commands work correctly.
Note: Most MCP commands require FreeCAD to be running.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, ClassVar
import pytest
from tests.just_commands.conftest import assert_command_executed
if TYPE_CHECKING:
from tests.just_commands.conftest import JustRunner
class TestMCPSyntax:
"""Syntax validation tests for MCP commands."""
MCP_COMMANDS: ClassVar[list[str]] = [
"mcp::check",
"mcp::run",
"mcp::run-debug",
"mcp::run-http",
]
@pytest.mark.just_syntax
@pytest.mark.parametrize("command", MCP_COMMANDS)
def test_mcp_command_syntax(self, just: JustRunner, command: str) -> None:
"""MCP command should have valid syntax."""
# run-http can take an optional port argument
if command == "mcp::run-http":
result = just.dry_run(command, "8080")
else:
result = just.dry_run(command)
assert result.success, f"Syntax error in '{command}': {result.stderr}"
class TestMCPRuntime:
"""Runtime tests for MCP commands.
Note: Most MCP commands require FreeCAD Robust MCP Bridge to be running.
The check command can run without FreeCAD and will fail gracefully.
"""
@pytest.mark.just_runtime
def test_check_runs_and_reports_status(self, just: JustRunner) -> None:
"""Check command should run and report bridge status.
This will likely fail (no bridge running) but should not crash.
"""
result = just.run("mcp::check", timeout=30)
# Command may fail if no bridge running, but should run without missing deps
assert_command_executed(result, "mcp::check")
# Should produce some output (verifies the command actually ran and
# reported something, without being brittle to specific wording)
assert result.output.strip(), "mcp::check produced no output"