mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use send_json_auto_id in some collection tests (#119570)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
8871090463
commit
9f322b20d1
@ -450,9 +450,8 @@ async def test_storage_collection_websocket(
|
|||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
# Create invalid
|
# Create invalid
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{
|
{
|
||||||
"id": 1,
|
|
||||||
"type": "test_item/collection/create",
|
"type": "test_item/collection/create",
|
||||||
"name": 1,
|
"name": 1,
|
||||||
# Forgot to add immutable_string
|
# Forgot to add immutable_string
|
||||||
@ -464,9 +463,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert len(changes) == 0
|
assert len(changes) == 0
|
||||||
|
|
||||||
# Create
|
# Create
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{
|
{
|
||||||
"id": 2,
|
|
||||||
"type": "test_item/collection/create",
|
"type": "test_item/collection/create",
|
||||||
"name": "Initial Name",
|
"name": "Initial Name",
|
||||||
"immutable_string": "no-changes",
|
"immutable_string": "no-changes",
|
||||||
@ -483,7 +481,7 @@ async def test_storage_collection_websocket(
|
|||||||
assert changes[0] == (collection.CHANGE_ADDED, "initial_name", response["result"])
|
assert changes[0] == (collection.CHANGE_ADDED, "initial_name", response["result"])
|
||||||
|
|
||||||
# List
|
# List
|
||||||
await client.send_json({"id": 3, "type": "test_item/collection/list"})
|
await client.send_json_auto_id({"type": "test_item/collection/list"})
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
assert response["result"] == [
|
assert response["result"] == [
|
||||||
@ -496,9 +494,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert len(changes) == 1
|
assert len(changes) == 1
|
||||||
|
|
||||||
# Update invalid data
|
# Update invalid data
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{
|
{
|
||||||
"id": 4,
|
|
||||||
"type": "test_item/collection/update",
|
"type": "test_item/collection/update",
|
||||||
"test_item_id": "initial_name",
|
"test_item_id": "initial_name",
|
||||||
"immutable_string": "no-changes",
|
"immutable_string": "no-changes",
|
||||||
@ -510,9 +507,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert len(changes) == 1
|
assert len(changes) == 1
|
||||||
|
|
||||||
# Update invalid item
|
# Update invalid item
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{
|
{
|
||||||
"id": 5,
|
|
||||||
"type": "test_item/collection/update",
|
"type": "test_item/collection/update",
|
||||||
"test_item_id": "non-existing",
|
"test_item_id": "non-existing",
|
||||||
"name": "Updated name",
|
"name": "Updated name",
|
||||||
@ -524,9 +520,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert len(changes) == 1
|
assert len(changes) == 1
|
||||||
|
|
||||||
# Update
|
# Update
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{
|
{
|
||||||
"id": 6,
|
|
||||||
"type": "test_item/collection/update",
|
"type": "test_item/collection/update",
|
||||||
"test_item_id": "initial_name",
|
"test_item_id": "initial_name",
|
||||||
"name": "Updated name",
|
"name": "Updated name",
|
||||||
@ -543,8 +538,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert changes[1] == (collection.CHANGE_UPDATED, "initial_name", response["result"])
|
assert changes[1] == (collection.CHANGE_UPDATED, "initial_name", response["result"])
|
||||||
|
|
||||||
# Delete invalid ID
|
# Delete invalid ID
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{"id": 7, "type": "test_item/collection/update", "test_item_id": "non-existing"}
|
{"type": "test_item/collection/update", "test_item_id": "non-existing"}
|
||||||
)
|
)
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert not response["success"]
|
assert not response["success"]
|
||||||
@ -552,8 +547,8 @@ async def test_storage_collection_websocket(
|
|||||||
assert len(changes) == 2
|
assert len(changes) == 2
|
||||||
|
|
||||||
# Delete
|
# Delete
|
||||||
await client.send_json(
|
await client.send_json_auto_id(
|
||||||
{"id": 8, "type": "test_item/collection/delete", "test_item_id": "initial_name"}
|
{"type": "test_item/collection/delete", "test_item_id": "initial_name"}
|
||||||
)
|
)
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user