Unreal-mcp/tests/test_tools/test_debug.py
StillHammer ee2092dada Implement complete Python MCP server with 12 tools and blueprint-workflow skill
- Add MCP server with real Unreal Remote Execution Protocol (UDP 6766 + TCP 6776)
- Implement 12 MCP tools: project intelligence, scene manipulation, debug/profiling, blueprint ops
- Add enhanced .uasset parser with UE4/UE5 support
- Create /blueprint-workflow skill (analyze, bp-to-cpp, cpp-to-bp, transform, optimize)
- Include 21 passing tests
- Add complete user documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 18:59:43 +07:00

67 lines
2.0 KiB
Python

"""Tests for debug tools."""
import pytest
from unittest.mock import MagicMock
from unreal_mcp.tools.debug import analyze_crash_dump
@pytest.mark.asyncio
async def test_analyze_crash_dump_null_pointer(
mock_connection: MagicMock,
) -> None:
"""Test crash dump analysis for null pointer."""
crash_log = """
Access violation - code c0000005 (first/second chance not available)
Unreal Engine is exiting due to D3D device being lost.
NullPointerException at Weapon.cpp:145
"""
result = await analyze_crash_dump(mock_connection, crash_log)
assert result["success"] is True
assert "Null pointer" in result["data"]["root_cause"]
assert result["data"]["file"] == "Weapon.cpp"
assert result["data"]["line"] == 145
@pytest.mark.asyncio
async def test_analyze_crash_dump_array_bounds(
mock_connection: MagicMock,
) -> None:
"""Test crash dump analysis for array out of bounds."""
crash_log = "Array index out of bounds: index 10 from array of size 5"
result = await analyze_crash_dump(mock_connection, crash_log)
assert result["success"] is True
assert "Array" in result["data"]["root_cause"]
assert "IsValidIndex" in result["data"]["fix_suggestion"]
@pytest.mark.asyncio
async def test_analyze_crash_dump_stack_overflow(
mock_connection: MagicMock,
) -> None:
"""Test crash dump analysis for stack overflow."""
crash_log = "Stack overflow error in recursive function call"
result = await analyze_crash_dump(mock_connection, crash_log)
assert result["success"] is True
assert "Stack overflow" in result["data"]["root_cause"]
@pytest.mark.asyncio
async def test_analyze_crash_dump_division_zero(
mock_connection: MagicMock,
) -> None:
"""Test crash dump analysis for division by zero."""
crash_log = "Divide by zero error in calculation"
result = await analyze_crash_dump(mock_connection, crash_log)
assert result["success"] is True
assert "Division by zero" in result["data"]["root_cause"]
assert "SMALL_NUMBER" in result["data"]["fix_suggestion"]