mirror of
https://github.com/esphome/esphome.git
synced 2026-10-22 13:56:10 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46bc9d6454 | ||
|
|
65a2f185d6 |
@@ -7,6 +7,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -32,9 +33,7 @@ async def test_micros_to_millis(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "micros-to-millis-test"
|
||||
await assert_device_name(client, "micros-to-millis-test")
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(all_passed.wait(), timeout=2.0)
|
||||
|
||||
@@ -7,6 +7,7 @@ import base64
|
||||
from aioesphomeapi import InvalidEncryptionKeyAPIError
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -40,9 +41,7 @@ async def test_noise_encryption_key_protection(
|
||||
# Reconnect with the original key to verify it still works
|
||||
async with api_client_connected(noise_psk=noise_psk) as client:
|
||||
# Verify connection is still successful with original key
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "noise-key-test"
|
||||
await assert_device_name(client, "noise-key-test")
|
||||
|
||||
# Verify that connecting with a wrong key fails
|
||||
wrong_key = base64.b64encode(b"y" * 32).decode() # Different key
|
||||
@@ -79,9 +78,7 @@ async def test_noise_encryption_key_clear_protection(
|
||||
# Reconnect with the original key to verify it still works
|
||||
async with api_client_connected(noise_psk=noise_psk) as client:
|
||||
# Verify connection is still successful with original key
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "noise-key-test"
|
||||
await assert_device_name(client, "noise-key-test")
|
||||
|
||||
# Verify that connecting with a wrong key fails
|
||||
wrong_key = base64.b64encode(b"y" * 32).decode() # Different key
|
||||
|
||||
@@ -28,6 +28,7 @@ import pytest
|
||||
from esphome.helpers import fnv1_hash_object_id
|
||||
|
||||
from .entity_utils import compute_object_id, verify_all_entities
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
# Host platform default MAC: 98:35:69:ab:f6:79 -> suffix "abf679"
|
||||
@@ -78,14 +79,8 @@ async def test_object_id_api_verification(
|
||||
4. Generic verification - all entities can have object_id computed from API data
|
||||
"""
|
||||
async with run_compiled(yaml_config), api_client_connected() as client:
|
||||
# Get device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
|
||||
# Device name should include MAC suffix (hyphen separator)
|
||||
assert device_info.name == f"object-id-test-{MAC_SUFFIX}", (
|
||||
f"Device name mismatch: got '{device_info.name}'"
|
||||
)
|
||||
device_info = await assert_device_name(client, f"object-id-test-{MAC_SUFFIX}")
|
||||
# Friendly name should include MAC suffix (space separator)
|
||||
expected_friendly_name = f"Test Device {MAC_SUFFIX}"
|
||||
assert device_info.friendly_name == expected_friendly_name, (
|
||||
|
||||
@@ -6,6 +6,7 @@ import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedWithDisconnectFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -36,9 +37,7 @@ async def test_oversized_payload_plaintext(
|
||||
async with run_compiled(yaml_config, line_callback=check_logs):
|
||||
async with api_client_connected_with_disconnect() as (client, disconnect_event):
|
||||
# Verify basic connection works first
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-plaintext"
|
||||
await assert_device_name(client, "oversized-plaintext")
|
||||
|
||||
# Create an oversized payload (>32768 bytes which is our new limit)
|
||||
oversized_data = b"X" * 40000 # ~40KiB, exceeds the 32768 byte limit
|
||||
@@ -64,9 +63,7 @@ async def test_oversized_payload_plaintext(
|
||||
|
||||
# Try to reconnect to verify the process is still running
|
||||
async with api_client_connected_with_disconnect() as (client2, _):
|
||||
device_info = await client2.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-plaintext"
|
||||
await assert_device_name(client2, "oversized-plaintext")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -98,9 +95,7 @@ async def test_oversized_protobuf_message_id_plaintext(
|
||||
async with run_compiled(yaml_config, line_callback=check_logs):
|
||||
async with api_client_connected_with_disconnect() as (client, disconnect_event):
|
||||
# Verify basic connection works first
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-protobuf-plaintext"
|
||||
await assert_device_name(client, "oversized-protobuf-plaintext")
|
||||
|
||||
# Access the internal connection to send raw message with large ID
|
||||
frame_helper = client._connection._frame_helper
|
||||
@@ -126,9 +121,7 @@ async def test_oversized_protobuf_message_id_plaintext(
|
||||
|
||||
# Try to reconnect to verify the process is still running
|
||||
async with api_client_connected_with_disconnect() as (client2, _):
|
||||
device_info = await client2.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-protobuf-plaintext"
|
||||
await assert_device_name(client2, "oversized-protobuf-plaintext")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -162,9 +155,7 @@ async def test_oversized_payload_noise(
|
||||
disconnect_event,
|
||||
):
|
||||
# Verify basic connection works first
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client, "oversized-noise")
|
||||
|
||||
# Create an oversized payload (>32768 bytes which is our new limit)
|
||||
oversized_data = b"Y" * 40000 # ~40KiB, exceeds the 32768 byte limit
|
||||
@@ -194,9 +185,7 @@ async def test_oversized_payload_noise(
|
||||
client2,
|
||||
_,
|
||||
):
|
||||
device_info = await client2.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client2, "oversized-noise")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -226,9 +215,7 @@ async def test_oversized_protobuf_message_id_noise(
|
||||
disconnect_event,
|
||||
):
|
||||
# Verify basic connection works first
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client, "oversized-noise")
|
||||
|
||||
# With noise, message types are uint16_t, so we test with an unknown but valid value
|
||||
frame_helper = client._connection._frame_helper
|
||||
@@ -251,9 +238,7 @@ async def test_oversized_protobuf_message_id_noise(
|
||||
)
|
||||
|
||||
# Verify we can still communicate by sending a valid request
|
||||
device_info2 = await client.device_info()
|
||||
assert device_info2 is not None
|
||||
assert device_info2.name == "oversized-noise"
|
||||
await assert_device_name(client, "oversized-noise")
|
||||
|
||||
# After test, verify process didn't crash
|
||||
assert not process_exited, "ESPHome process should not crash"
|
||||
@@ -263,9 +248,7 @@ async def test_oversized_protobuf_message_id_noise(
|
||||
client2,
|
||||
_,
|
||||
):
|
||||
device_info = await client2.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client2, "oversized-noise")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -305,9 +288,7 @@ async def test_noise_corrupt_encrypted_frame(
|
||||
disconnect_event,
|
||||
):
|
||||
# Verify basic connection works first
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client, "oversized-noise")
|
||||
|
||||
# Get the socket to send raw corrupt data
|
||||
socket = client._connection._socket
|
||||
@@ -346,6 +327,4 @@ async def test_noise_corrupt_encrypted_frame(
|
||||
client2,
|
||||
_,
|
||||
):
|
||||
device_info = await client2.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "oversized-noise"
|
||||
await assert_device_name(client2, "oversized-noise")
|
||||
|
||||
@@ -30,7 +30,7 @@ from esphome.helpers import fnv1_hash, fnv1_hash_name, fnv1_hash_object_id
|
||||
|
||||
from .conftest import run_binary_and_wait_for_port, wait_and_connect_api_client
|
||||
from .host_prefs import clear_host_prefs, write_host_prefs
|
||||
from .state_utils import InitialStateHelper, require_entity
|
||||
from .state_utils import InitialStateHelper, assert_device_name, require_entity
|
||||
from .types import CompileFunction, ConfigWriter
|
||||
|
||||
DEVICE_NAME = "host-pref-key-stability"
|
||||
@@ -91,8 +91,7 @@ async def test_preference_key_stability(
|
||||
run_binary_and_wait_for_port(binary_path, "127.0.0.1", port),
|
||||
wait_and_connect_api_client(port=port) as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info.name == DEVICE_NAME
|
||||
await assert_device_name(client, DEVICE_NAME)
|
||||
|
||||
entities, _ = await client.list_entities_services()
|
||||
switch_entity = require_entity(
|
||||
|
||||
@@ -12,7 +12,7 @@ import re
|
||||
from aioesphomeapi import ButtonInfo
|
||||
import pytest
|
||||
|
||||
from .state_utils import require_entity
|
||||
from .state_utils import assert_device_name, require_entity
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ async def test_scheduler_background_wake(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-background-wake"
|
||||
await assert_device_name(client, "scheduler-background-wake")
|
||||
entities, _ = await client.list_entities_services()
|
||||
for object_id, delay in (
|
||||
("start_scheduler_timeout", 100),
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -66,9 +67,7 @@ async def test_scheduler_bulk_cleanup(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-bulk-cleanup"
|
||||
await assert_device_name(client, "scheduler-bulk-cleanup")
|
||||
|
||||
# List entities and services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import asyncio
|
||||
from aioesphomeapi import EntityState, Event, EventInfo, UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -18,9 +19,7 @@ async def test_scheduler_defer_cancel(
|
||||
|
||||
async with run_compiled(yaml_config), api_client_connected() as client:
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-defer-cancel"
|
||||
await assert_device_name(client, "scheduler-defer-cancel")
|
||||
|
||||
# List entities and services
|
||||
entity_info, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import asyncio
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -40,9 +41,7 @@ async def test_scheduler_defer_cancels_regular(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-defer-cancel-regular"
|
||||
await assert_device_name(client, "scheduler-defer-cancel-regular")
|
||||
|
||||
# List services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import asyncio
|
||||
from aioesphomeapi import EntityState, Event, EventInfo, UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -18,9 +19,7 @@ async def test_scheduler_defer_fifo_simple(
|
||||
|
||||
async with run_compiled(yaml_config), api_client_connected() as client:
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-defer-fifo-simple"
|
||||
await assert_device_name(client, "scheduler-defer-fifo-simple")
|
||||
|
||||
# List entities and services
|
||||
entity_info, services = await asyncio.wait_for(
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -62,9 +63,7 @@ async def test_scheduler_defer_stress(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-defer-stress-test"
|
||||
await assert_device_name(client, "scheduler-defer-stress-test")
|
||||
|
||||
# List entities and services
|
||||
entity_info, services = await asyncio.wait_for(
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -67,9 +68,7 @@ async def test_scheduler_heap_stress(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-heap-stress-test"
|
||||
await assert_device_name(client, "scheduler-heap-stress-test")
|
||||
|
||||
# List entities and services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -11,6 +11,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -74,9 +75,7 @@ async def test_scheduler_internal_id_no_collision(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-internal-id-test"
|
||||
await assert_device_name(client, "scheduler-internal-id-test")
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(all_tests_complete.wait(), timeout=5.0)
|
||||
|
||||
@@ -19,6 +19,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -81,9 +82,7 @@ async def test_scheduler_interval_reschedule(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "sched-interval-resched"
|
||||
await assert_device_name(client, "sched-interval-resched")
|
||||
|
||||
# 1. Fast interval (50ms) should reach 10 fires within ~600ms
|
||||
try:
|
||||
|
||||
@@ -17,6 +17,7 @@ import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -44,9 +45,7 @@ async def test_scheduler_interval_zero_coerced(
|
||||
# The API-client connection itself is evidence that the main loop
|
||||
# is not starved — if set_interval(0) were spinning we could not
|
||||
# get here at all.
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "sched-interval-zero"
|
||||
await assert_device_name(client, "sched-interval-zero")
|
||||
|
||||
# Coerce warning must fire at registration
|
||||
try:
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -32,9 +33,7 @@ async def test_scheduler_null_name(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-null-name"
|
||||
await assert_device_name(client, "scheduler-null-name")
|
||||
|
||||
# List services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -120,9 +121,7 @@ async def test_scheduler_numeric_id_test(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-numeric-id-test"
|
||||
await assert_device_name(client, "scheduler-numeric-id-test")
|
||||
|
||||
# Wait for numeric timeout tests
|
||||
try:
|
||||
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -88,9 +89,7 @@ async def test_scheduler_pool(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device is running
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-pool-test"
|
||||
await assert_device_name(client, "scheduler-pool-test")
|
||||
|
||||
# Get list of services
|
||||
entities, services = await client.list_entities_services()
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -76,9 +77,7 @@ async def test_scheduler_rapid_cancellation(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "sched-rapid-cancel-test"
|
||||
await assert_device_name(client, "sched-rapid-cancel-test")
|
||||
|
||||
# List entities and services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import asyncio
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -47,9 +48,7 @@ async def test_scheduler_recursive_timeout(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "sched-recursive-timeout"
|
||||
await assert_device_name(client, "sched-recursive-timeout")
|
||||
|
||||
# List entities and services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -67,9 +68,7 @@ async def test_scheduler_removed_item_race(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-removed-item-race"
|
||||
await assert_device_name(client, "scheduler-removed-item-race")
|
||||
|
||||
# List services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -12,6 +12,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -61,9 +62,7 @@ async def test_scheduler_self_keyed(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-self-keyed-test"
|
||||
await assert_device_name(client, "scheduler-self-keyed-test")
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(all_tests_complete.wait(), timeout=5.0)
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from aioesphomeapi import UserService
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -66,9 +67,7 @@ async def test_scheduler_simultaneous_callbacks(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "sched-simul-callbacks-test"
|
||||
await assert_device_name(client, "sched-simul-callbacks-test")
|
||||
|
||||
# List entities and services
|
||||
_, services = await asyncio.wait_for(
|
||||
|
||||
@@ -5,6 +5,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -115,9 +116,7 @@ async def test_scheduler_string_test(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify we can connect
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "scheduler-string-test"
|
||||
await assert_device_name(client, "scheduler-string-test")
|
||||
|
||||
# Wait for static string tests
|
||||
try:
|
||||
|
||||
@@ -20,6 +20,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -79,9 +80,7 @@ async def test_script_delay_with_params(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "test-script-delay-params"
|
||||
await assert_device_name(client, "test-script-delay-params")
|
||||
|
||||
# Get services
|
||||
_, services = await client.list_entities_services()
|
||||
|
||||
@@ -24,6 +24,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -85,9 +86,7 @@ async def test_script_wait_on_boot(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "test-script-wait-on-boot"
|
||||
await assert_device_name(client, "test-script-wait-on-boot")
|
||||
|
||||
# Wait for on_boot sequence to complete
|
||||
# The boot sequence should complete automatically
|
||||
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -89,9 +90,7 @@ async def test_select_stringref_trigger(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "select-stringref-test"
|
||||
await assert_device_name(client, "select-stringref-test")
|
||||
|
||||
# List entities to find our select
|
||||
entities, _ = await client.list_entities_services()
|
||||
|
||||
@@ -6,6 +6,7 @@ import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -39,9 +40,7 @@ async def test_socket_ipv4_resolve(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "socket-ipv4-resolve-test"
|
||||
await assert_device_name(client, "socket-ipv4-resolve-test")
|
||||
|
||||
await wait_or_fail(test_complete, 10.0, "IPv4 resolve test timed out")
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import contextlib
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -78,9 +79,7 @@ async def test_socket_tcp_client_link(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "socket-tcp-client-link-test"
|
||||
await assert_device_name(client, "socket-tcp-client-link-test")
|
||||
|
||||
await wait_or_fail(echo_done, 15.0, "Link never connected or echoed")
|
||||
assert echoed and echoed[0] == PAYLOAD, "Echo payload mismatch"
|
||||
|
||||
@@ -17,6 +17,7 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -43,9 +44,7 @@ async def test_socket_wake_gate_tcp(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "socket-wake-gate-tcp"
|
||||
await assert_device_name(client, "socket-wake-gate-tcp")
|
||||
|
||||
await wait_or_fail(
|
||||
boot_done, 15.0, "BOOT_DONE never appeared — device did not complete boot"
|
||||
|
||||
@@ -7,7 +7,7 @@ import asyncio
|
||||
from aioesphomeapi import EntityState, TextSensorState
|
||||
import pytest
|
||||
|
||||
from .state_utils import InitialStateHelper, require_entity
|
||||
from .state_utils import InitialStateHelper, assert_device_name, require_entity
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -20,9 +20,7 @@ async def test_strftime_to(
|
||||
) -> None:
|
||||
"""Test ESPTime::strftime_to() formats time correctly."""
|
||||
async with run_compiled(yaml_config), api_client_connected() as client:
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "strftime-to-test"
|
||||
await assert_device_name(client, "strftime-to-test")
|
||||
|
||||
# Get entities
|
||||
entities, _ = await client.list_entities_services()
|
||||
|
||||
@@ -13,6 +13,7 @@ from typing import TypedDict
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -172,9 +173,7 @@ async def test_syslog(
|
||||
|
||||
async with run_compiled(config), api_client_connected() as client:
|
||||
# Verify device is running
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "syslog-test"
|
||||
await assert_device_name(client, "syslog-test")
|
||||
|
||||
# Wait for syslog messages (ESPHome logs during startup)
|
||||
try:
|
||||
|
||||
@@ -13,6 +13,7 @@ import contextlib
|
||||
import pytest
|
||||
|
||||
from .log_utils import LineWaiter
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -71,9 +72,7 @@ async def test_tcp_uart_bridge(
|
||||
run_compiled(yaml_config, line_callback=lines.callback),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "tcp-uart-bridge-test"
|
||||
await assert_device_name(client, "tcp-uart-bridge-test")
|
||||
_, services = await client.list_entities_services()
|
||||
send_byte = next(s for s in services if s.name == "send_byte")
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import contextlib
|
||||
import pytest
|
||||
|
||||
from .log_utils import LineWaiter
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
PAYLOAD = b"ping!"
|
||||
@@ -34,9 +35,7 @@ async def test_tcp_uart_server(
|
||||
run_compiled(yaml_config, line_callback=lines.callback),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "tcp-uart-server-test"
|
||||
await assert_device_name(client, "tcp-uart-server-test")
|
||||
await lines.wait_for(f"Listening on {allowed_port}")
|
||||
await lines.wait_for(f"Listening on {denied_port}")
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import pytest
|
||||
|
||||
from .conftest import run_binary_and_wait_for_port, wait_and_connect_api_client
|
||||
from .host_prefs import clear_host_prefs
|
||||
from .state_utils import InitialStateHelper, require_entity
|
||||
from .state_utils import InitialStateHelper, assert_device_name, require_entity
|
||||
from .types import CompileFunction, ConfigWriter
|
||||
|
||||
DEVICE_NAME = "host-template-text-save-test"
|
||||
@@ -56,8 +56,7 @@ async def test_template_text_save(
|
||||
),
|
||||
wait_and_connect_api_client(port=port) as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info.name == DEVICE_NAME
|
||||
await assert_device_name(client, DEVICE_NAME)
|
||||
|
||||
entities, _ = await client.list_entities_services()
|
||||
text_entity = require_entity(
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import Any
|
||||
from aioesphomeapi import TextInfo, TextState
|
||||
import pytest
|
||||
|
||||
from .state_utils import InitialStateHelper, require_entity
|
||||
from .state_utils import InitialStateHelper, assert_device_name, require_entity
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ async def test_text_command(
|
||||
loop = asyncio.get_running_loop()
|
||||
async with run_compiled(yaml_config), api_client_connected() as client:
|
||||
# Verify we can get device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "host-text-command-test"
|
||||
await assert_device_name(client, "host-text-command-test")
|
||||
|
||||
# Get list of entities
|
||||
entities, _ = await client.list_entities_services()
|
||||
|
||||
@@ -14,6 +14,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -131,9 +132,7 @@ async def test_text_sensor_raw_state(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "test-text-sensor-raw-state"
|
||||
await assert_device_name(client, "test-text-sensor-raw-state")
|
||||
|
||||
# Get entities to find our buttons
|
||||
entities, _ = await client.list_entities_services()
|
||||
|
||||
@@ -14,6 +14,7 @@ import pathlib
|
||||
import pytest
|
||||
|
||||
from .log_utils import LineWaiter
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -73,9 +74,7 @@ async def test_uart_tcp_bridge(
|
||||
run_compiled(yaml_config, line_callback=lines.callback),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "uart-tcp-bridge-test"
|
||||
await assert_device_name(client, "uart-tcp-bridge-test")
|
||||
await lines.wait_for("Listening on")
|
||||
|
||||
# Bytes written before any client connects must never reach one.
|
||||
|
||||
@@ -11,6 +11,7 @@ import socket
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -128,9 +129,7 @@ async def test_udp_send_receive(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device is running
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "udp-test"
|
||||
await assert_device_name(client, "udp-test")
|
||||
|
||||
# Get services
|
||||
_, services = await client.list_entities_services()
|
||||
|
||||
@@ -7,6 +7,7 @@ import socket
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -47,9 +48,7 @@ async def test_udp_multicast_join(
|
||||
run_compiled(config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "udp-multicast-test"
|
||||
await assert_device_name(client, "udp-multicast-test")
|
||||
|
||||
await wait_or_fail(
|
||||
joined_event, 5.0, "Multicast group was not joined", log_lines=log_lines
|
||||
|
||||
@@ -12,6 +12,7 @@ import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -36,9 +37,7 @@ async def test_use_address_runtime(
|
||||
run_compiled(yaml_config, line_callback=check_output),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "use-address-runtime"
|
||||
await assert_device_name(client, "use-address-runtime")
|
||||
|
||||
await wait_or_fail(
|
||||
address_seen, 10.0, "Did not log 'Address: use-address-runtime.local:'"
|
||||
@@ -63,8 +62,6 @@ async def test_use_address_runtime_mac_suffix(
|
||||
run_compiled(yaml_config, line_callback=check_output),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == f"use-address-mac-{MAC_SUFFIX}"
|
||||
await assert_device_name(client, f"use-address-mac-{MAC_SUFFIX}")
|
||||
|
||||
await wait_or_fail(address_seen, 10.0, f"Did not log '{expected}'")
|
||||
|
||||
@@ -14,6 +14,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -60,9 +61,7 @@ async def test_wait_until_fifo_ordering(
|
||||
api_client_connected() as client,
|
||||
):
|
||||
# Verify device info
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "test-wait-until-ordering"
|
||||
await assert_device_name(client, "test-wait-until-ordering")
|
||||
|
||||
# Get services
|
||||
_, services = await client.list_entities_services()
|
||||
|
||||
@@ -15,6 +15,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
from .wait_utils import wait_or_fail
|
||||
|
||||
@@ -50,9 +51,7 @@ async def test_wait_until_reentrant_restart(
|
||||
run_compiled(yaml_config, line_callback=check_output),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "wait-until-reentrant-restart"
|
||||
await assert_device_name(client, "wait-until-reentrant-restart")
|
||||
|
||||
_, services = await client.list_entities_services()
|
||||
self_restart_service = next(
|
||||
|
||||
@@ -24,6 +24,7 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from .state_utils import assert_device_name
|
||||
from .types import APIClientConnectedFactory, RunCompiledFunction
|
||||
|
||||
|
||||
@@ -48,9 +49,7 @@ async def test_wake_loop_forces_phase_b(
|
||||
run_compiled(yaml_config, line_callback=on_log_line),
|
||||
api_client_connected() as client,
|
||||
):
|
||||
device_info = await client.device_info()
|
||||
assert device_info is not None
|
||||
assert device_info.name == "wake-loop-phase-b"
|
||||
await assert_device_name(client, "wake-loop-phase-b")
|
||||
|
||||
try:
|
||||
delta, elapsed = await asyncio.wait_for(result, timeout=15.0)
|
||||
|
||||
Reference in New Issue
Block a user