Fixed imports and lint
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user