Skip to content

Commit

Permalink
Add tests for transient connection states
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Sep 13, 2022
1 parent c479e12 commit 4d5f00f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/ably/realtimeconnection_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from ably.realtime.connection import ConnectionState
import pytest
from ably.util.exceptions import AblyAuthException
Expand All @@ -18,6 +19,22 @@ async def test_auth_connection(self):
await ably.close()
assert ably.connection.state == ConnectionState.CLOSED

async def test_connecting_state(self):
ably = await RestSetup.get_ably_realtime()
task = asyncio.create_task(ably.connect())
await asyncio.sleep(0)
assert ably.connection.state == ConnectionState.CONNECTING
await task
await ably.close()

async def test_closing_state(self):
ably = await RestSetup.get_ably_realtime()
await ably.connect()
task = asyncio.create_task(ably.close())
await asyncio.sleep(0)
assert ably.connection.state == ConnectionState.CLOSING
await task

async def test_auth_invalid_key(self):
ably = await RestSetup.get_ably_realtime(key=self.valid_key_format)
with pytest.raises(AblyAuthException):
Expand Down

0 comments on commit 4d5f00f

Please sign in to comment.