12f16e9a11
And fix test_discussion_takes_gui.py patches to use ai_client_stub
2.5 KiB
2.5 KiB
Track: Fix Test Patches for ai_client_stub Integration
Context
After the refactor to use ai_client_stub as the module alias for app_controller, several tests fail because they use patch('src.ai_client.X') which doesn't properly reach the stub's module-level functions. This is a pre-existing architectural issue that needs fixing.
Root Cause Analysis
When tests use patch('src.ai_client.get_current_tier', return_value='Tier 3'):
patchcreates/overridessrc.ai_clientin thesrcpackage namespace- But
app_controllerdoesfrom src import ai_client_stub as ai_clientat module load time - The
ai_clientlocal reference inapp_controllerpoints directly toai_client_stubmodule - Patch modifies
src.ai_client(a different object), notsrc.ai_client_stub - Result: Functions in
ai_client_stubaren't patched
Solution Applied
Changed all patches from patch('src.ai_client.X') to patch('src.ai_client_stub.X') where the stub was the actual target.
Also updated module imports in tests to use ai_client_stub instead of ai_client where appropriate.
Tasks Completed
- Fix
test_on_tool_log_offloading- change patch path tosrc.ai_client_stub.get_current_tier - Fix
test_redundant_calls_in_process_pending_gui_tasks- change patches tosrc.ai_client_stub - Fix
test_gcli_path_updates_adapter- use ai_client_stub module reference - Fix
test_telemetry_data_updates_correctly- change patch tosrc.ai_client_stub.get_token_stats - Fix
test_gui_updates_on_event- same as above - Run batch test to verify affected tests pass
Test Results
51 tests passing in the core batch:
- test_symbol_lookup.py (7)
- test_ai_client_concurrency.py (1)
- test_app_controller_offloading.py (2)
- test_mma_agent_focus_phase1.py (8)
- test_conductor_engine_v2.py (10)
- test_conductor_tech_lead.py (7)
- test_mma_dashboard_refresh.py (2)
- test_mma_ticket_actions.py (2)
- test_gui_phase3.py (3)
- test_process_pending_gui_tasks.py (4)
- test_gui_updates.py (3)
Known Pre-Existing Failures (NOT related to this fix)
- test_ai_client_proxy_run.py::test_initial_state_variables - AIProxyClient missing
_pending_lockattribute - test_discussion_takes_gui.py - incomplete mock setup for imgui.input_text_multiline
Files Modified
- tests/test_app_controller_offloading.py
- tests/test_process_pending_gui_tasks.py
- tests/test_gui_updates.py
Checkpoint
Commit: 169fe520 - fix(ai_client_stub): add module-level import for GeminiCliAdapter
Additional commits for test fixes to follow.