|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import json |
5 | 6 | from unittest.mock import AsyncMock, MagicMock |
6 | 7 |
|
7 | 8 | import pytest |
@@ -259,6 +260,13 @@ async def test_operations_mode_rejects_group_and_member_in_same_batch() -> None: |
259 | 260 | Operations mode has no ``exclude_entity_ids`` to express that intent, |
260 | 261 | so the omission alone never protected it; the only safe response is to |
261 | 262 | reject the whole batch rather than silently dispatch it. |
| 263 | +
|
| 264 | + Also confirmed live: the rejection message alone was not enough. The |
| 265 | + calling model retried four times with a broken selector call -- |
| 266 | + ``exclude_entity_ids`` at the top level (it belongs inside ``selector``) |
| 267 | + and area *display names* where exact ``area_id`` registry values were |
| 268 | + required -- and never recovered. The message must show a concrete, |
| 269 | + correctly-shaped example, not just name selector mode. |
262 | 270 | """ |
263 | 271 | device_tools = MagicMock() |
264 | 272 | device_tools.bulk_device_control = AsyncMock(return_value={"success": True}) |
@@ -293,9 +301,17 @@ async def test_operations_mode_rejects_group_and_member_in_same_batch() -> None: |
293 | 301 | # caller's (unenforceable, in this mode) attempt to exclude it. |
294 | 302 | ] |
295 | 303 |
|
296 | | - with pytest.raises(ToolError, match="group/aggregate entity"): |
| 304 | + with pytest.raises(ToolError) as exc_info: |
297 | 305 | await tools.ha_bulk_control(operations, False) |
298 | 306 |
|
| 307 | + message = json.loads(str(exc_info.value))["error"]["message"] |
| 308 | + assert "group/aggregate entity" in message |
| 309 | + # The worked example must show exclude_entity_ids nested INSIDE |
| 310 | + # selector -- not as a sibling argument, which is the exact mistake |
| 311 | + # observed live. |
| 312 | + assert '"selector": {"domain": "light"' in message |
| 313 | + assert '"exclude_entity_ids"' in message |
| 314 | + assert "ha_list_floors_areas" in message |
299 | 315 | device_tools.bulk_device_control.assert_not_awaited() |
300 | 316 |
|
301 | 317 |
|
|
0 commit comments