mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-22 16:48:04 +01:00
Add test for trying to finish an unstarted connection (#706)
This commit is contained in:
parent
3abf9ff8d4
commit
3711d54ffa
@ -568,7 +568,7 @@ class APIConnection:
|
||||
than starts the keep alive process.
|
||||
"""
|
||||
if self.connection_state is not ConnectionState.SOCKET_OPENED:
|
||||
raise ValueError(
|
||||
raise RuntimeError(
|
||||
"Connection must be in SOCKET_OPENED state to finish connection"
|
||||
)
|
||||
finish_connect_task = asyncio.create_task(
|
||||
|
@ -784,3 +784,12 @@ async def test_connection_cannot_be_reused(
|
||||
await connect_task
|
||||
with pytest.raises(RuntimeError):
|
||||
await conn.start_connection()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_attempting_to_finish_unstarted_connection(
|
||||
conn: APIConnection,
|
||||
) -> None:
|
||||
"""Test that we raise when trying to finish an unstarted connection."""
|
||||
with pytest.raises(RuntimeError):
|
||||
await conn.finish_connection(login=False)
|
||||
|
Loading…
Reference in New Issue
Block a user