test: fix async generator mock for U3 streaming orchestrator #18

Merged
fischer merged 1 commits from fix/async-generator-mock-tests into main 2026-07-02 22:57:16 +08:00
Owner

U3 streaming refactor switched orchestrator from agent.execute() to agent.execute_stream() (async gen), but tests still mocked execute(). AsyncMock() returns a coroutine lacking __aiter__, causing:

  • 'async for' requires an object with __aiter__ method, got coroutine
  • RuntimeWarning: coroutine was never awaited

Changes

Add shared helpers in tests/unit/experts/_helpers.py:

  • make_chat_stream_mock: async gen for gateway.chat_stream
  • make_execute_stream_mock: async gen yielding final_answer event
  • make_execute_stream_raising_mock: async gen that raises (for failure tests)

Update 3 test files to use the helpers:

  • test_team_orchestrator.py: _make_mock_expert, _make_mock_pool, failure tests, assertion updates, synthesizer warning cleanup
  • test_pm_collaboration.py: _make_mock_expert, _make_mock_llm_gateway, collaboration/risk/rework assertions
  • test_board_orchestrator.py: _make_mock_gateway (warning cleanup)

Verification

All 483 tests/unit/experts/ tests pass with 0 warnings.

U3 streaming refactor switched orchestrator from `agent.execute()` to `agent.execute_stream()` (async gen), but tests still mocked `execute()`. `AsyncMock()` returns a coroutine lacking `__aiter__`, causing: - `'async for' requires an object with __aiter__ method, got coroutine` - `RuntimeWarning: coroutine was never awaited` ## Changes Add shared helpers in `tests/unit/experts/_helpers.py`: - `make_chat_stream_mock`: async gen for `gateway.chat_stream` - `make_execute_stream_mock`: async gen yielding `final_answer` event - `make_execute_stream_raising_mock`: async gen that raises (for failure tests) Update 3 test files to use the helpers: - `test_team_orchestrator.py`: `_make_mock_expert`, `_make_mock_pool`, failure tests, assertion updates, synthesizer warning cleanup - `test_pm_collaboration.py`: `_make_mock_expert`, `_make_mock_llm_gateway`, collaboration/risk/rework assertions - `test_board_orchestrator.py`: `_make_mock_gateway` (warning cleanup) ## Verification All 483 `tests/unit/experts/` tests pass with 0 warnings.
fischer added 1 commit 2026-07-02 22:53:56 +08:00
Test / backend-test (pull_request) Has been cancelled Details
Test / frontend-unit (pull_request) Has been cancelled Details
Test / api-e2e (pull_request) Has been cancelled Details
Test / frontend-e2e (pull_request) Has been cancelled Details
1599d193c7
test: fix async generator mock for U3 streaming orchestrator
U3 streaming refactor switched orchestrator from agent.execute() to
agent.execute_stream() (async gen), but tests still mocked execute().
AsyncMock() returns a coroutine lacking __aiter__, causing:
- 'async for' requires an object with __aiter__ method, got coroutine
- RuntimeWarning: coroutine was never awaited

Add shared helpers in tests/unit/experts/_helpers.py:
- make_chat_stream_mock: async gen for gateway.chat_stream
- make_execute_stream_mock: async gen yielding final_answer event
- make_execute_stream_raising_mock: async gen that raises (for failure tests)

Update 3 test files to use the helpers:
- test_team_orchestrator.py: _make_mock_expert, _make_mock_pool,
  failure tests (phase_failed, all_phases_fail, fallback_uses_lead,
  phase_failure_marks_dependents), assertion updates (execute_stream
  instead of execute), synthesizer warning cleanup
- test_pm_collaboration.py: _make_mock_expert, _make_mock_llm_gateway,
  collaboration/risk/rework assertions
- test_board_orchestrator.py: _make_mock_gateway (warning cleanup)

All 483 experts/ tests pass with 0 warnings.
fischer merged commit 6826ceb2a9 into main 2026-07-02 22:57:16 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fischer/fischer-agentkit#18
No description provided.