update test expectations
This commit is contained in:
parent
78fbbd54cd
commit
59d57756f1
3 changed files with 30 additions and 24 deletions
|
|
@ -29,6 +29,7 @@ def test_something():
|
|||
expected = """
|
||||
import pytest
|
||||
from app.api.routes.agent import clone_agent_template
|
||||
|
||||
def test_something():
|
||||
pass
|
||||
"""
|
||||
|
|
@ -73,6 +74,7 @@ def test_something():
|
|||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from app.api.routes.agent import clone_agent_template
|
||||
|
||||
class MockArangoService:
|
||||
async def clone_agent_template(self, template_id):
|
||||
"""This method should NOT be replaced"""
|
||||
|
|
@ -121,6 +123,7 @@ async def clone_agent_template(request, template_id):
|
|||
expected = '''
|
||||
import pytest
|
||||
from app.api.routes.agent import clone_agent_template
|
||||
|
||||
def some_other_function():
|
||||
pass
|
||||
|
||||
|
|
@ -165,6 +168,7 @@ class OuterClass:
|
|||
expected = '''
|
||||
import pytest
|
||||
from app.api.routes.agent import clone_agent_template
|
||||
|
||||
class OuterClass:
|
||||
class InnerClass:
|
||||
async def clone_agent_template(self, template_id):
|
||||
|
|
@ -208,6 +212,7 @@ def test_something():
|
|||
expected = """
|
||||
import pytest
|
||||
from app.api.routes.agent import SomeAgent
|
||||
|
||||
def test_something():
|
||||
pass
|
||||
"""
|
||||
|
|
@ -287,6 +292,7 @@ class MockLogger:
|
|||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from app.api.routes.agent import clone_agent_template
|
||||
|
||||
class FaultyArangoService:
|
||||
async def clone_agent_template(self, template_id):
|
||||
raise RuntimeError("Clone error")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ async def test_hello_world_basic():
|
|||
assert result == "World"
|
||||
'''
|
||||
|
||||
result = validate_testgen_code(async_test_code, (3, 11, 0))
|
||||
result = validate_testgen_code(async_test_code, (3, 11))
|
||||
assert "async def test_hello_world_basic" in result
|
||||
assert "@pytest.mark.asyncio" in result
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ async def test_async_function():
|
|||
assert result == "async"
|
||||
'''
|
||||
|
||||
result = validate_testgen_code(mixed_test_code, (3, 11, 0))
|
||||
result = validate_testgen_code(mixed_test_code, (3, 11))
|
||||
assert "def test_sync_function" in result
|
||||
assert "async def test_async_function" in result
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class TestAsync(unittest.TestCase):
|
|||
self.assertEqual(2, 2)
|
||||
'''
|
||||
|
||||
result = validate_testgen_code(async_unittest_code, (3, 11, 0))
|
||||
result = validate_testgen_code(async_unittest_code, (3, 11))
|
||||
assert "async def test_async_method" in result
|
||||
assert "def test_sync_method" in result
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ async def another_helper():
|
|||
'''
|
||||
|
||||
with pytest.raises(ValueError, match="No test functions were found"):
|
||||
validate_testgen_code(no_test_code, (3, 11, 0))
|
||||
validate_testgen_code(no_test_code, (3, 11))
|
||||
|
||||
|
||||
def test_async_function_with_complex_decorators() -> None:
|
||||
|
|
@ -109,7 +109,7 @@ async def test_with_multiple_decorators(mock_obj):
|
|||
assert True
|
||||
'''
|
||||
|
||||
result = validate_testgen_code(complex_decorator_code, (3, 11, 0))
|
||||
result = validate_testgen_code(complex_decorator_code, (3, 11))
|
||||
assert "async def test_with_multiple_decorators" in result
|
||||
assert "@pytest.mark.asyncio" in result
|
||||
assert "@patch" in result
|
||||
|
|
|
|||
|
|
@ -11,18 +11,18 @@ def test_valid_code() -> None:
|
|||
y = 2
|
||||
return x + y"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == code
|
||||
|
||||
|
||||
def test_empty_code() -> None:
|
||||
with pytest.raises(ValueError, match="No code was generated when generating tests"):
|
||||
validate_testgen_code("", python_version=(3, 11, 0))
|
||||
validate_testgen_code("", python_version=(3, 11))
|
||||
|
||||
|
||||
def test_whitespace_only() -> None:
|
||||
with pytest.raises(ValueError, match="No code was generated when generating tests"):
|
||||
validate_testgen_code(" \n \n", python_version=(3, 11, 0))
|
||||
validate_testgen_code(" \n \n", python_version=(3, 11))
|
||||
|
||||
|
||||
def test_incomplete_function_definition() -> None:
|
||||
|
|
@ -33,7 +33,7 @@ def test_incomplete_function_definition() -> None:
|
|||
expected: str = """def test_function():
|
||||
x = 1"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def test_truncation_limit() -> None:
|
|||
with pytest.raises(
|
||||
ValueError, match=f"Invalid test code generated, failed to validate code even after removing {max_lines} lines"
|
||||
):
|
||||
validate_testgen_code(code, python_version=(3, 11, 0), max_lines_to_remove=max_lines)
|
||||
validate_testgen_code(code, python_version=(3, 11), max_lines_to_remove=max_lines)
|
||||
|
||||
|
||||
def test_incomplete_statement_at_end() -> None:
|
||||
|
|
@ -59,7 +59,7 @@ def test_incomplete_statement_at_end() -> None:
|
|||
expected: str = """def test_function():
|
||||
x = 1"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ def test_syntax_error_in_middle() -> None:
|
|||
return x + y"""
|
||||
|
||||
with pytest.raises(ValueError, match="Invalid test code generated"):
|
||||
validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
validate_testgen_code(code, python_version=(3, 11))
|
||||
|
||||
|
||||
def test_multiple_functions_with_error() -> None:
|
||||
|
|
@ -91,14 +91,14 @@ def test_function2():
|
|||
x = 1
|
||||
return x"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_just_def() -> None:
|
||||
code: str = "def test_"
|
||||
with pytest.raises(ValueError, match="Invalid test code generated"):
|
||||
validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
validate_testgen_code(code, python_version=(3, 11))
|
||||
|
||||
|
||||
def test_broken_def() -> None:
|
||||
|
|
@ -117,14 +117,14 @@ def"""
|
|||
def test_function2():
|
||||
x = 1
|
||||
return x"""
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_pytest_style() -> None:
|
||||
code: str = """def test_something():
|
||||
pass"""
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == code
|
||||
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ def test_unittest_style() -> None:
|
|||
code: str = """class TestCase(unittest.TestCase):
|
||||
def test_something(self):
|
||||
pass"""
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == code
|
||||
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ def test_no_test_function() -> None:
|
|||
code: str = """def something():
|
||||
pass"""
|
||||
with pytest.raises(ValueError, match="No test functions were found in the generated code"):
|
||||
validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
validate_testgen_code(code, python_version=(3, 11))
|
||||
|
||||
|
||||
def test_unittest_without_test_prefix() -> None:
|
||||
|
|
@ -148,7 +148,7 @@ def test_unittest_without_test_prefix() -> None:
|
|||
def something(self):
|
||||
pass"""
|
||||
with pytest.raises(ValueError, match="No test functions were found in the generated code"):
|
||||
validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
validate_testgen_code(code, python_version=(3, 11))
|
||||
|
||||
|
||||
def test_remove_lines_with_test() -> None:
|
||||
|
|
@ -159,7 +159,7 @@ class MyTests(TestCase):
|
|||
def tes"""
|
||||
expected: str = """def test_one():
|
||||
pass"""
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ def test_function():
|
|||
x: list[int] = [1, 2, 3]
|
||||
return x[0]"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ def test_function():
|
|||
x: list[int] = [1, 2, 3]
|
||||
return x[0]"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ def test_function():
|
|||
x: list[int] = [1, 2, 3]
|
||||
return x[0]"""
|
||||
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11, 0))
|
||||
result: str = validate_testgen_code(code, python_version=(3, 11))
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
@ -440,4 +440,4 @@ def test_file_part_bytes_empty_string(worker):
|
|||
assert content.media_...
|
||||
"""
|
||||
|
||||
assert validate_testgen_code(code, python_version=(3, 11, 0), max_lines_to_remove=40)
|
||||
assert validate_testgen_code(code, python_version=(3, 11), max_lines_to_remove=40)
|
||||
|
|
|
|||
Loading…
Reference in a new issue