x
This commit is contained in:
@@ -68,7 +68,9 @@ class TestHelperFunctions:
|
||||
store_pre_state(test_path, test_content)
|
||||
|
||||
# Verify cache directory created
|
||||
mock_mkdir.assert_called_once_with(exist_ok=True)
|
||||
mock_mkdir.assert_called_once()
|
||||
_, mkdir_kwargs = mock_mkdir.call_args
|
||||
assert mkdir_kwargs.get("exist_ok") is True
|
||||
|
||||
# Verify state was written
|
||||
mock_write.assert_called_once()
|
||||
@@ -226,6 +228,9 @@ class TestHelperFunctions:
|
||||
duplicate_enabled=False,
|
||||
complexity_enabled=False,
|
||||
modernization_enabled=False,
|
||||
sourcery_enabled=False,
|
||||
basedpyright_enabled=False,
|
||||
pyrefly_enabled=False,
|
||||
)
|
||||
|
||||
with patch("code_quality_guard.detect_internal_duplicates") as mock_dup:
|
||||
|
||||
@@ -6,6 +6,8 @@ import tempfile
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestHookIntegration:
|
||||
"""Test complete hook integration scenarios."""
|
||||
@@ -179,11 +181,9 @@ class TestHookIntegration:
|
||||
},
|
||||
},
|
||||
):
|
||||
try:
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
main()
|
||||
raise AssertionError("Expected SystemExit")
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 2
|
||||
assert exc_info.value.code == 2
|
||||
|
||||
response = json.loads(mock_print.call_args[0][0])
|
||||
assert (
|
||||
@@ -223,7 +223,11 @@ class TestHookIntegration:
|
||||
"tool_name": "Write",
|
||||
"tool_input": {
|
||||
"file_path": str(temp_python_file),
|
||||
"content": "def func1(): pass\ndef func2(): pass\ndef func3(): pass",
|
||||
"content": (
|
||||
"def func1(): pass\n"
|
||||
"def func2(): pass\n"
|
||||
"def func3(): pass"
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -315,11 +319,9 @@ class TestHookIntegration:
|
||||
},
|
||||
):
|
||||
if expected in {"deny", "ask"}:
|
||||
try:
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
main()
|
||||
raise AssertionError("Expected SystemExit")
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 2
|
||||
assert exc_info.value.code == 2
|
||||
else:
|
||||
main()
|
||||
|
||||
|
||||
@@ -149,7 +149,10 @@ class TestPostToolUseHook:
|
||||
with patch("pathlib.Path.read_text", return_value=clean_code):
|
||||
result = posttooluse_hook(hook_data, config)
|
||||
assert result["decision"] == "approve"
|
||||
assert "passed post-write verification" in result["systemMessage"].lower()
|
||||
assert (
|
||||
"passed post-write verification"
|
||||
in result["systemMessage"].lower()
|
||||
)
|
||||
|
||||
def test_no_message_when_success_disabled(self, clean_code):
|
||||
"""Test no message when show_success is disabled."""
|
||||
|
||||
@@ -356,7 +356,10 @@ class TestPreToolUseHook:
|
||||
},
|
||||
{
|
||||
"old_string": "pass",
|
||||
"new_string": "def handler(arg: Any) -> str:\n return str(arg)\n",
|
||||
"new_string": (
|
||||
"def handler(arg: Any) -> str:\n"
|
||||
" return str(arg)\n"
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user