feat: replace Aider with secure mini-SWE-agent worker
This commit is contained in:
60
tests/test_git_workspace.py
Normal file
60
tests/test_git_workspace.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import subprocess
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from lai_automation.git import GitWorkspace
|
||||
from lai_automation.models import ChangeSummary
|
||||
|
||||
|
||||
def test_check_diff_accepts_clean_changed_file(settings, tmp_path: Path) -> None:
|
||||
workspace = GitWorkspace(replace(settings, workspace_root=tmp_path), 1)
|
||||
workspace.path.mkdir(parents=True)
|
||||
(workspace.path / "app.php").write_text("<?php\nreturn true;\n")
|
||||
workspace._git = Mock(
|
||||
side_effect=[
|
||||
subprocess.CompletedProcess([], 0, "", ""),
|
||||
subprocess.CompletedProcess([], 0, "app.php\n", ""),
|
||||
]
|
||||
)
|
||||
|
||||
workspace.check_diff(ChangeSummary(("app.php",), 2, 0))
|
||||
|
||||
assert workspace._git.call_count == 2
|
||||
|
||||
|
||||
def test_check_diff_rejects_trailing_whitespace_in_untracked_file(
|
||||
settings,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
workspace = GitWorkspace(replace(settings, workspace_root=tmp_path), 1)
|
||||
workspace.path.mkdir(parents=True)
|
||||
(workspace.path / "app.php").write_text("<?php \n")
|
||||
workspace._git = Mock(
|
||||
side_effect=[
|
||||
subprocess.CompletedProcess([], 0, "", ""),
|
||||
subprocess.CompletedProcess([], 0, "app.php\n", ""),
|
||||
]
|
||||
)
|
||||
|
||||
with pytest.raises(RuntimeError, match="trailing whitespace"):
|
||||
workspace.check_diff(ChangeSummary(("app.php",), 1, 0))
|
||||
|
||||
|
||||
def test_check_diff_ignores_unchanged_whitespace_in_tracked_file(
|
||||
settings,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
workspace = GitWorkspace(replace(settings, workspace_root=tmp_path), 1)
|
||||
workspace.path.mkdir(parents=True)
|
||||
(workspace.path / "legacy.php").write_text("<?php \nreturn true;\n")
|
||||
workspace._git = Mock(
|
||||
side_effect=[
|
||||
subprocess.CompletedProcess([], 0, "", ""),
|
||||
subprocess.CompletedProcess([], 0, "", ""),
|
||||
]
|
||||
)
|
||||
|
||||
workspace.check_diff(ChangeSummary(("legacy.php",), 1, 0))
|
||||
Reference in New Issue
Block a user