mirror of
https://github.com/home-assistant/core.git
synced 2026-09-12 10:06:22 -05:00
Address review comments for Picnic (#104732)
This commit is contained in:
@@ -56,31 +56,16 @@ async def init_integration(
|
||||
return mock_config_entry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ws_req_id() -> Callable[[], int]:
|
||||
"""Fixture for incremental websocket requests."""
|
||||
|
||||
id = 0
|
||||
|
||||
def next_id() -> int:
|
||||
nonlocal id
|
||||
id += 1
|
||||
return id
|
||||
|
||||
return next_id
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def get_items(
|
||||
hass_ws_client: WebSocketGenerator, ws_req_id: Callable[[], int]
|
||||
hass_ws_client: WebSocketGenerator
|
||||
) -> Callable[[], Awaitable[dict[str, str]]]:
|
||||
"""Fixture to fetch items from the todo websocket."""
|
||||
|
||||
async def get() -> list[dict[str, str]]:
|
||||
# Fetch items using To-do platform
|
||||
client = await hass_ws_client()
|
||||
id = ws_req_id()
|
||||
await client.send_json(
|
||||
await client.send_json_auto_id(
|
||||
{
|
||||
"id": id,
|
||||
"type": "todo/item/list",
|
||||
@@ -88,7 +73,6 @@ async def get_items(
|
||||
}
|
||||
)
|
||||
resp = await client.receive_json()
|
||||
assert resp.get("id") == id
|
||||
assert resp.get("success")
|
||||
return resp.get("result", {}).get("items", [])
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.todo import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
|
||||
from .conftest import ENTITY_ID
|
||||
|
||||
@@ -115,7 +116,7 @@ async def test_create_todo_list_item_not_found(
|
||||
mock_picnic_api.search = Mock()
|
||||
mock_picnic_api.search.return_value = [{"items": []}]
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"add_item",
|
||||
|
||||
Reference in New Issue
Block a user