1
0
mirror of https://github.com/esphome/esphome.git synced 2025-07-15 03:23:22 +01:00
Files
esphome/tests/integration/test_host_mode_reconnect.py
2025-05-26 21:31:32 -05:00

29 lines
919 B
Python

"""Integration test for Host mode reconnection."""
from __future__ import annotations
import pytest
from .types import APIClientConnectedFactory, RunCompiledFunction
@pytest.mark.asyncio
async def test_host_mode_reconnect(
yaml_config: str,
run_compiled: RunCompiledFunction,
api_client_connected: APIClientConnectedFactory,
) -> None:
"""Test reconnecting to a Host mode device."""
# Write, compile and run the ESPHome device
async with run_compiled(yaml_config):
# First connection
async with api_client_connected() as client:
device_info = await client.device_info()
assert device_info is not None
# Reconnect with a new client
async with api_client_connected() as client2:
device_info2 = await client2.device_info()
assert device_info2 is not None
assert device_info2.name == device_info.name