Fixed imports and lint

This commit is contained in:
Fahad
2025-06-16 06:24:33 +04:00
parent b43b30b49d
commit 903aabd311
6 changed files with 27 additions and 40 deletions

View File

@@ -160,7 +160,6 @@ class TestAutoMode:
patch("providers.registry.ModelProviderRegistry.get_provider_for_model") as mock_provider,
patch("providers.registry.ModelProviderRegistry.get_available_models") as mock_available,
patch.object(tool, "_get_available_models") as mock_tool_available,
patch("providers.registry.ModelProviderRegistry.is_model_available") as mock_is_available,
):
# Mock that o3 is not available but actual available models are
@@ -199,12 +198,6 @@ class TestAutoMode:
# Mock the tool's available models method to return the actual available models
mock_tool_available.return_value = available_models
# Mock is_model_available to return False for o3 specifically
def mock_model_available(model_name):
return model_name != "o3" and model_name in available_models
mock_is_available.side_effect = mock_model_available
# Execute with unavailable model
result = await tool.execute(
{"files": ["/tmp/test.py"], "prompt": "Analyze this", "model": "o3"} # This model is not available

View File

@@ -150,6 +150,7 @@ class TestLargePromptHandling:
async def test_codereview_large_focus(self, large_prompt):
"""Test that codereview tool detects large focus_on field."""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
tool = CodeReviewTool()

View File

@@ -127,20 +127,20 @@ class TestComprehensive(unittest.TestCase):
def test_request_model_validation(self):
"""Test request model validation"""
# Valid request
valid_request = TestGenRequest(files=["/tmp/test.py"], prompt="Generate tests for calculator functions")
valid_request = TestGenerationRequest(files=["/tmp/test.py"], prompt="Generate tests for calculator functions")
assert valid_request.files == ["/tmp/test.py"]
assert valid_request.prompt == "Generate tests for calculator functions"
assert valid_request.test_examples is None
# With test examples
request_with_examples = TestGenRequest(
request_with_examples = TestGenerationRequest(
files=["/tmp/test.py"], prompt="Generate tests", test_examples=["/tmp/test_example.py"]
)
assert request_with_examples.test_examples == ["/tmp/test_example.py"]
# Invalid request (missing required fields)
with pytest.raises(ValueError):
TestGenRequest(files=["/tmp/test.py"]) # Missing prompt
TestGenerationRequest(files=["/tmp/test.py"]) # Missing prompt
@pytest.mark.asyncio
@patch("tools.base.BaseTool.get_model_provider")
@@ -244,7 +244,7 @@ class TestComprehensive(unittest.TestCase):
@pytest.mark.asyncio
async def test_prepare_prompt_structure(self, tool, temp_files):
"""Test prompt preparation structure"""
request = TestGenRequest(files=[temp_files["code_file"]], prompt="Test the calculator functions")
request = TestGenerationRequest(files=[temp_files["code_file"]], prompt="Test the calculator functions")
with patch.object(tool, "_prepare_file_content_for_prompt") as mock_prepare:
mock_prepare.return_value = ("mocked file content", [temp_files["code_file"]])
@@ -261,7 +261,7 @@ class TestComprehensive(unittest.TestCase):
@pytest.mark.asyncio
async def test_prepare_prompt_with_examples(self, tool, temp_files):
"""Test prompt preparation with test examples"""
request = TestGenRequest(
request = TestGenerationRequest(
files=[temp_files["code_file"]], prompt="Generate tests", test_examples=[temp_files["small_test"]]
)
@@ -280,7 +280,7 @@ class TestComprehensive(unittest.TestCase):
def test_format_response(self, tool):
"""Test response formatting"""
request = TestGenRequest(files=["/tmp/test.py"], prompt="Generate tests")
request = TestGenerationRequest(files=["/tmp/test.py"], prompt="Generate tests")
raw_response = "Generated test cases with edge cases"
formatted = tool.format_response(raw_response, request)
@@ -333,7 +333,7 @@ class TestComprehensive(unittest.TestCase):
with patch.object(tool, "_prepare_file_content_for_prompt") as mock_prepare:
mock_prepare.return_value = ("code content", ["/tmp/test.py"])
request = TestGenRequest(
request = TestGenerationRequest(
files=["/tmp/test.py"], prompt="Test prompt", test_examples=["/tmp/example.py"]
)
@@ -353,7 +353,7 @@ class TestComprehensive(unittest.TestCase):
with patch.object(tool, "_prepare_file_content_for_prompt") as mock_prepare:
mock_prepare.return_value = ("code content", [temp_files["code_file"]])
request = TestGenRequest(
request = TestGenerationRequest(
files=[temp_files["code_file"]], prompt="Continue testing", continuation_id="test-thread-123"
)
@@ -372,7 +372,7 @@ class TestComprehensive(unittest.TestCase):
def test_no_websearch_in_prompt(self, tool, temp_files):
"""Test that web search instructions are not included"""
request = TestGenRequest(files=[temp_files["code_file"]], prompt="Generate tests")
request = TestGenerationRequest(files=[temp_files["code_file"]], prompt="Generate tests")
with patch.object(tool, "_prepare_file_content_for_prompt") as mock_prepare:
mock_prepare.return_value = ("code content", [temp_files["code_file"]])
@@ -391,7 +391,7 @@ class TestComprehensive(unittest.TestCase):
# Create a scenario where the same file appears in both files and test_examples
duplicate_file = temp_files["code_file"]
request = TestGenRequest(
request = TestGenerationRequest(
files=[duplicate_file, temp_files["large_test"]], # code_file appears in both
prompt="Generate tests",
test_examples=[temp_files["small_test"], duplicate_file], # code_file also here
@@ -423,7 +423,7 @@ class TestComprehensive(unittest.TestCase):
@pytest.mark.asyncio
async def test_no_deduplication_when_no_test_examples(self, tool, temp_files):
"""Test that no deduplication occurs when test_examples is None/empty"""
request = TestGenRequest(
request = TestGenerationRequest(
files=[temp_files["code_file"], temp_files["large_test"]],
prompt="Generate tests",
# No test_examples
@@ -453,7 +453,7 @@ class TestComprehensive(unittest.TestCase):
# Add some path variations that should normalize to the same file
variant_path = os.path.join(os.path.dirname(base_file), ".", os.path.basename(base_file))
request = TestGenRequest(
request = TestGenerationRequest(
files=[variant_path, temp_files["large_test"]], # variant path in files
prompt="Generate tests",
test_examples=[base_file], # base path in test_examples

View File

@@ -41,7 +41,6 @@ class TestThinkingModes:
@pytest.mark.asyncio
async def test_thinking_mode_minimal(self):
"""Test minimal thinking mode"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
with patch("tools.base.BaseTool.get_model_provider") as mock_get_provider:
@@ -91,7 +90,6 @@ class TestThinkingModes:
@pytest.mark.asyncio
async def test_thinking_mode_low(self):
"""Test low thinking mode"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
with patch("tools.base.BaseTool.get_model_provider") as mock_get_provider:
@@ -136,7 +134,6 @@ class TestThinkingModes:
@pytest.mark.asyncio
async def test_thinking_mode_medium(self):
"""Test medium thinking mode (default for most tools)"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
with patch("tools.base.BaseTool.get_model_provider") as mock_get_provider:
@@ -180,7 +177,6 @@ class TestThinkingModes:
@pytest.mark.asyncio
async def test_thinking_mode_high(self):
"""Test high thinking mode"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
with patch("tools.base.BaseTool.get_model_provider") as mock_get_provider:

View File

@@ -78,7 +78,6 @@ class TestCodeReviewTool:
@pytest.mark.asyncio
async def test_execute_with_review_type(self, tool, tmp_path):
"""Test execution with specific review type"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
# Create test file
@@ -184,7 +183,6 @@ class TestAnalyzeTool:
@pytest.mark.asyncio
async def test_execute_with_analysis_type(self, tool, tmp_path):
"""Test execution with specific analysis type"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
# Create test file
@@ -329,7 +327,6 @@ class TestAbsolutePathValidation:
@pytest.mark.asyncio
async def test_analyze_tool_accepts_absolute_paths(self):
"""Test that analyze tool accepts absolute paths"""
from unittest.mock import MagicMock
from providers.base import ModelCapabilities, ProviderType
tool = AnalyzeTool()