Address review comments for Picnic (#104732)

This commit is contained in:
Duco Sebel
2023-11-29 18:35:55 +01:00
committed by GitHub
parent 38eda9f46e
commit 1727c19e0d
3 changed files with 7 additions and 23 deletions
+2 -18
View File
@@ -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", [])
+2 -1
View File
@@ -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",