68 lines
2.0 KiB
Python
68 lines
2.0 KiB
Python
"""Tests for FixAgent."""
|
|
|
|
import pytest
|
|
|
|
from app.agents.fix_agent import FixAgent
|
|
|
|
|
|
@pytest.fixture
|
|
def fix_agent():
|
|
return FixAgent()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_initialization(fix_agent):
|
|
"""Test FixAgent initializes correctly."""
|
|
assert fix_agent.name == "fix_agent"
|
|
assert fix_agent.version == "1.0.0"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_health_check(fix_agent):
|
|
"""Test FixAgent health check."""
|
|
result = await fix_agent.health_check()
|
|
assert isinstance(result, bool)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_run(fix_agent):
|
|
"""Test FixAgent run."""
|
|
result = await fix_agent.run({"action": "suggest"})
|
|
assert hasattr(result, "success")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_analyze(fix_agent):
|
|
"""Test FixAgent analyze."""
|
|
context = {
|
|
"bug_data": {
|
|
"error_message": "AttributeError: 'NoneType' object has no attribute 'id'",
|
|
}
|
|
}
|
|
result = await fix_agent._analyze_bug(context)
|
|
assert result.success
|
|
assert "analysis" in result.data
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_identify_error_type(fix_agent):
|
|
"""Test FixAgent error type identification."""
|
|
assert fix_agent._identify_error_type("AttributeError: 'NoneType'") == "AttributeError"
|
|
assert fix_agent._identify_error_type("ValueError: invalid value") == "ValueError"
|
|
assert fix_agent._identify_error_type("KeyError: 'id'") == "KeyError"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_suggest_fixes(fix_agent):
|
|
"""Test FixAgent suggest fixes."""
|
|
result = await fix_agent._suggest_fixes({})
|
|
assert result.success
|
|
assert "suggestions" in result.data
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_fix_agent_severity_assessment(fix_agent):
|
|
"""Test FixAgent severity assessment."""
|
|
assert fix_agent._assess_severity("security vulnerability") == "critical"
|
|
assert fix_agent._assess_severity("crash on startup") == "high"
|
|
assert fix_agent._assess_severity("minor bug") == "medium" |