Add test for trying to finish an unstarted connection (#706)

This commit is contained in:
J. Nick Koston 2023-11-25 08:44:25 -06:00 committed by GitHub
parent 3abf9ff8d4
commit 3711d54ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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(

View File

@ -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)