Skip to content

Commit 479a571

Browse files
tclaude
andcommitted
fix(test/worker): assert on envelope-wrapped result shape (#7154)
worker_node was refactored to wrap task results in a {status, message, data} envelope. Two tests asserted on the unwrapped shape: test_llm_chat_completion_success — expected `result["response"]` test_kb_search_success — expected `result["results"]` With the Redis mock now actually applied (post-#6987 src.* fix), these failures became visible. They had been silently passing on stale-mock-luck during the entire src.* bug window. Fix: update both tests to drill through `result["data"]` to the canonical position. Add inline reference to #7154 explaining the shape. Audit (per AC): traced execute_task → task_executor.execute → handlers. Envelope is applied PER-HANDLER (consistent for task results). The unwrapped helper-method returns at worker_node.py:104 / 206 / 215 etc. are internal helpers, not user-facing task results — no drift surface to file as a follow-up. Acceptance criteria met: - ✅ Both tests updated to assert on `result["data"]["response"]` / `result["data"]["results"]` — verified by 2/2 pass - ✅ Envelope-pattern audit complete: handlers wrap consistently; helper-method returns are internal-only Closes #7154 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 282a420 commit 479a571

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎autobot-backend/worker_node_test.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ async def test_llm_chat_completion_success(self, worker_node):
117117

118118
result = await worker_node.execute_task(task_payload)
119119

120+
# #7154: worker_node now wraps every response in a {status, message,
121+
# data} envelope. The actual response sits at result["data"]["response"].
120122
assert result["status"] == "success"
121-
assert "response" in result
123+
assert "data" in result
124+
assert "response" in result["data"]
122125
worker_node.llm_interface.chat_completion.assert_called_once()
123126
worker_node.security_layer.audit_log.assert_called()
124127

@@ -137,8 +140,10 @@ async def test_kb_search_success(self, worker_node):
137140

138141
result = await worker_node.execute_task(task_payload)
139142

143+
# #7154: worker_node envelope — actual results at result["data"]["results"].
140144
assert result["status"] == "success"
141-
assert "results" in result
145+
assert "data" in result
146+
assert "results" in result["data"]
142147
worker_node.knowledge_base.search.assert_called_once_with("test query", 5)
143148

144149
@pytest.mark.asyncio

0 commit comments

Comments
 (0)