feat(mma): Implement run_tier4_analysis in ai_client.py

This commit is contained in:
2026-02-26 20:22:04 -05:00
parent bb2f7a16d4
commit 8e4e32690c
2 changed files with 63 additions and 0 deletions

View File

@@ -100,3 +100,29 @@ def test_run_powershell_optional_qa_callback():
assert "STDERR:\nerror" in output
assert "EXIT CODE: 1" in output
def test_end_to_end_tier4_integration():
"""
Verifies that shell_runner.run_powershell correctly uses ai_client.run_tier4_analysis.
"""
import ai_client
script = "Invoke-Item non_existent_file"
base_dir = "."
stderr_content = "Invoke-Item : Cannot find path 'C:\\non_existent_file' because it does not exist."
mock_result = MagicMock()
mock_result.stdout = ""
mock_result.stderr = stderr_content
mock_result.returncode = 1
expected_analysis = "Path does not exist. Verify the file path and ensure the file is present before invoking."
with patch("subprocess.run", return_value=mock_result), \
patch("shutil.which", return_value="powershell.exe"), \
patch("ai_client.run_tier4_analysis", return_value=expected_analysis) as mock_analysis:
output = run_powershell(script, base_dir, qa_callback=ai_client.run_tier4_analysis)
mock_analysis.assert_called_once_with(stderr_content)
assert f"QA ANALYSIS:\n{expected_analysis}" in output