feat(types): Complete strict static analysis and typing track
This commit is contained in:
@@ -10,7 +10,7 @@ import datetime
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Generator, Any
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import patch
|
||||
|
||||
# Ensure project root is in path for imports
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
@@ -41,7 +41,7 @@ class VerificationLogger:
|
||||
})
|
||||
|
||||
def finalize(self, title: str, status: str, result_msg: str) -> None:
|
||||
elapsed = round(time.time() - self.start_time, 2)
|
||||
round(time.time() - self.start_time, 2)
|
||||
log_file = self.logs_dir / f"{self.script_name}.txt"
|
||||
with open(log_file, "w", encoding="utf-8") as f:
|
||||
f.write(f"[ Test: {self.test_name} ]\n")
|
||||
|
||||
@@ -60,7 +60,6 @@ def main() -> None:
|
||||
return
|
||||
|
||||
# 2. Check for multi-round tool triggers
|
||||
is_resume_list = is_resume and 'list_directory' in prompt
|
||||
is_resume_read = is_resume and 'read_file' in prompt
|
||||
is_resume_powershell = is_resume and 'run_powershell' in prompt
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
import ai_client
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
import ai_client
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
import os
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
# Ensure project root is in path for imports
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
@@ -3,7 +3,6 @@ Tests for architecture_boundary_hardening_20260302 — Phase 2.
|
||||
Tasks 2.1-2.4: MCP tool config exposure + MUTATING_TOOLS + HITL enforcement.
|
||||
"""
|
||||
import tomllib
|
||||
import pytest
|
||||
from project_manager import default_project
|
||||
|
||||
MUTATING_TOOLS = {"set_file_slice", "py_update_definition", "py_set_signature", "py_set_var_declaration"}
|
||||
@@ -101,9 +100,8 @@ def test_mutating_tools_excludes_read_tools():
|
||||
|
||||
def test_mutating_tool_triggers_pre_tool_callback(monkeypatch):
|
||||
"""When a mutating tool is called and pre_tool_callback is set, it must be invoked."""
|
||||
import ai_client
|
||||
import mcp_client
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
callback_called = []
|
||||
def fake_callback(desc, base_dir, qa_cb):
|
||||
callback_called.append(desc)
|
||||
@@ -113,12 +111,11 @@ def test_mutating_tool_triggers_pre_tool_callback(monkeypatch):
|
||||
tool_name = "set_file_slice"
|
||||
args = {"path": "foo.py", "start_line": 1, "end_line": 2, "new_content": "x"}
|
||||
# Simulate the logic from all 4 provider dispatch blocks
|
||||
out = ""
|
||||
_res = fake_callback(f"# MCP MUTATING TOOL: {tool_name}", ".", None)
|
||||
if _res is None:
|
||||
out = "USER REJECTED: tool execution cancelled"
|
||||
pass
|
||||
else:
|
||||
out = mcp_client.dispatch(tool_name, args)
|
||||
mcp_client.dispatch(tool_name, args)
|
||||
assert len(callback_called) == 1, "pre_tool_callback must be called for mutating tools"
|
||||
assert mock_dispatch.called
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from models import Ticket
|
||||
from dag_engine import TrackDAG, ExecutionEngine
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from models import Ticket
|
||||
from dag_engine import TrackDAG, ExecutionEngine
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ from unittest.mock import patch, MagicMock
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
# Ensure the project root is in sys.path to resolve imports correctly
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
@@ -68,7 +68,7 @@ def test_gemini_cli_parameter_resilience(live_gui: Any) -> None:
|
||||
bridge_path_str = bridge_path.replace("\\", "/")
|
||||
else:
|
||||
bridge_path_str = bridge_path
|
||||
with open(alias_tool_content := "tests/mock_alias_tool.py", "w") as f:
|
||||
with open("tests/mock_alias_tool.py", "w") as f:
|
||||
f.write(f'''import sys, json, os, subprocess
|
||||
prompt = sys.stdin.read()
|
||||
if '"role": "tool"' in prompt:
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
from typing import Generator
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from gui_2 import App
|
||||
|
||||
def test_gui2_hubs_exist_in_show_windows(app_instance: App) -> None:
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
from typing import Generator
|
||||
from gui_2 import App
|
||||
import ai_client
|
||||
from events import EventEmitter
|
||||
|
||||
def test_mcp_tool_call_is_dispatched(app_instance: App) -> None:
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
import sys
|
||||
import os
|
||||
from typing import Any
|
||||
@@ -7,7 +5,6 @@ from typing import Any
|
||||
# Ensure project root is in path for imports
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from gui_2 import App
|
||||
|
||||
def test_diagnostics_panel_initialization(app_instance: Any) -> None:
|
||||
assert "Diagnostics" in app_instance.show_windows
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
from typing import Generator, Any
|
||||
from gui_2 import App
|
||||
import ai_client
|
||||
|
||||
# Ensure project root is in path
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
def test_gui_updates_on_event(app_instance: App) -> None:
|
||||
mock_stats = {"percentage": 50.0, "current": 500, "limit": 1000}
|
||||
app_instance.last_md = "mock_md"
|
||||
with patch.object(app_instance, '_refresh_api_metrics') as mock_refresh:
|
||||
# Simulate event (bypassing events.emit since _init_ai_and_hooks is mocked)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from gui_2 import App
|
||||
|
||||
def test_track_proposal_editing(app_instance):
|
||||
# Setup some proposed tracks
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from gui_2 import App
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
import sys
|
||||
import os
|
||||
@@ -41,7 +40,7 @@ def test_performance_history_updates(app_instance: Any) -> None:
|
||||
def test_gui_updates_on_event(app_instance: App) -> None:
|
||||
mock_stats = {"percentage": 50.0, "current": 500, "limit": 1000}
|
||||
app_instance.last_md = "mock_md"
|
||||
with patch('ai_client.get_token_stats', return_value=mock_stats) as mock_get_stats:
|
||||
with patch('ai_client.get_token_stats', return_value=mock_stats):
|
||||
app_instance._on_api_event(payload={"text": "test"})
|
||||
app_instance._process_pending_gui_tasks()
|
||||
assert app_instance._token_stats["percentage"] == 50.0
|
||||
|
||||
@@ -6,7 +6,6 @@ from unittest.mock import patch
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from api_hook_client import ApiHookClient
|
||||
import gui_2
|
||||
|
||||
def test_hooks_enabled_via_cli(mock_app) -> None:
|
||||
with patch.object(sys, 'argv', ['gui_2.py', '--enable-test-hooks']):
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
Tests for mma_agent_focus_ux_20260302 — Phase 1: Tier Tagging at Emission.
|
||||
These tests are written RED-first: they fail before implementation.
|
||||
"""
|
||||
from typing import Generator
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
import ai_client
|
||||
from gui_2 import App
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""
|
||||
Tests for mma_agent_focus_ux_20260302 — Phase 3: Focus Agent UI + Filter Logic.
|
||||
"""
|
||||
from typing import Generator
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from gui_2 import App
|
||||
|
||||
|
||||
def test_ui_focus_agent_state_var_exists(app_instance):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
import time
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
from typing import Generator
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import patch
|
||||
from gui_2 import App
|
||||
|
||||
def test_cb_ticket_retry(app_instance: App) -> None:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import sys
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
"""Tests for context & token visualization (Track: context_token_viz_20260301)."""
|
||||
from typing import Generator
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
import ai_client
|
||||
from ai_client import _add_bleed_derived, get_history_bleed_stats
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import time
|
||||
from api_hook_client import ApiHookClient
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
|
||||
def test_vlogger_available(vlogger):
|
||||
vlogger.log_state("Test", "Before", "After")
|
||||
|
||||
Reference in New Issue
Block a user