Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy: &strategy
matrix:
python-version: ["3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "fishjam-server-sdk"
version = "0.26.0"
description = "Python server SDK for the Fishjam"
authors = [{ name = "Fishjam Team", email = "contact@fishjam.io" }]
requires-python = ">=3.11"
requires-python = ">=3.10"
readme = "README.md"
Comment thread
roznawsk marked this conversation as resolved.
license = "Apache-2.0"
dependencies = [
Expand Down
101 changes: 52 additions & 49 deletions tests/test_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ async def test_valid_credentials(self):
def handle_notitifcation(_notification):
pass

async with asyncio.TaskGroup() as tg:
notifier_task = tg.create_task(notifier.connect())
await notifier.wait_ready()
notifier_task = asyncio.ensure_future(notifier.connect())
await notifier.wait_ready()

assert (
notifier._websocket
and notifier._websocket.state == websockets.State.OPEN
)
assert (
notifier._websocket
and notifier._websocket.state == websockets.State.OPEN
)

notifier_task.cancel()
notifier_task.cancel()
try:
await notifier_task
except asyncio.CancelledError:
pass
Comment on lines +83 to +95


@pytest.fixture
Expand All @@ -114,20 +117,22 @@ async def test_room_created_deleted(
):
event_checks = [ServerMessageRoomCreated, ServerMessageRoomDeleted]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
await notifier.wait_ready()
assert_task = asyncio.ensure_future(assert_events(notifier, event_checks.copy()))
notifier_task = asyncio.ensure_future(notifier.connect())
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)
options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)

room_api.delete_room(room.id)
room_api.delete_room(room.id)

await assert_task
await assert_task

notifier_task.cancel()
notifier_task.cancel()
try:
await notifier_task
except asyncio.CancelledError:
pass
Comment on lines +120 to +135

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand All @@ -144,28 +149,27 @@ async def test_peer_connected_disconnected(
ServerMessageRoomDeleted,
]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
await notifier.wait_ready()
assert_task = asyncio.ensure_future(assert_events(notifier, event_checks.copy()))
notifier_task = asyncio.ensure_future(notifier.connect())
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)
options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)

peer, token = room_api.create_peer(room.id)
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = tg.create_task(peer_socket.connect(token))
peer, token = room_api.create_peer(room.id)
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = asyncio.ensure_future(peer_socket.connect(token))

await peer_socket.wait_ready()
await peer_socket.wait_ready()

room_api.delete_peer(room.id, peer.id)
room_api.delete_room(room.id)
room_api.delete_peer(room.id, peer.id)
room_api.delete_room(room.id)

await assert_task
await assert_task

notifier_task.cancel()
peer_socket_task.cancel()
notifier_task.cancel()
peer_socket_task.cancel()
await asyncio.gather(notifier_task, peer_socket_task, return_exceptions=True)
Comment on lines +152 to +172

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand All @@ -181,27 +185,26 @@ async def test_peer_connected_room_deleted(
ServerMessageRoomDeleted,
]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
await notifier.wait_ready()
assert_task = asyncio.ensure_future(assert_events(notifier, event_checks.copy()))
notifier_task = asyncio.ensure_future(notifier.connect())
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)
_peer, token = room_api.create_peer(room.id)
options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)
_peer, token = room_api.create_peer(room.id)

peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = tg.create_task(peer_socket.connect(token))
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = asyncio.ensure_future(peer_socket.connect(token))

await peer_socket.wait_ready()
await peer_socket.wait_ready()

room_api.delete_room(room.id)
room_api.delete_room(room.id)

await assert_task
await assert_task

notifier_task.cancel()
peer_socket_task.cancel()
notifier_task.cancel()
peer_socket_task.cancel()
await asyncio.gather(notifier_task, peer_socket_task, return_exceptions=True)
Comment on lines +188 to +207

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand Down