Skip to content

Commit f6aa081

Browse files
Fix tests and bump protos
1 parent 9b75437 commit f6aa081

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

fishjam/_ws_notifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async def _receive_loop(self):
130130
raise RuntimeError("Notification handler is not defined")
131131

132132
while True:
133-
message = cast(bytes, await self._websocket.recv())
133+
message = await self._websocket.recv(decode=False)
134134
message = ServerMessage().parse(message)
135135
_which, message = betterproto.which_one_of(message, "content")
136136

tests/test_notifier.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ def handle_notitifcation(_notification):
5757
pass
5858

5959
async with asyncio.TaskGroup() as tg:
60-
tg.create_task(notifier.connect())
60+
notifier_task = tg.create_task(notifier.connect())
6161
await notifier.wait_ready()
6262

6363
assert (
6464
notifier._websocket
6565
and notifier._websocket.state == websockets.State.OPEN
6666
)
6767

68+
notifier_task.cancel()
69+
6870

6971
@pytest.fixture
7072
def room_api():
@@ -91,7 +93,7 @@ async def test_room_created_deleted(
9193
async with asyncio.TaskGroup() as tg:
9294
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))
9395

94-
tg.create_task(notifier.connect())
96+
notifier_task = tg.create_task(notifier.connect())
9597
await notifier.wait_ready()
9698

9799
options = RoomOptions(webhook_url=WEBHOOK_URL)
@@ -101,6 +103,8 @@ async def test_room_created_deleted(
101103

102104
await assert_task
103105

106+
notifier_task.cancel()
107+
104108
for event in event_checks:
105109
self.assert_event(event)
106110

@@ -120,15 +124,15 @@ async def test_peer_connected_disconnected(
120124
async with asyncio.TaskGroup() as tg:
121125
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))
122126

123-
tg.create_task(notifier.connect())
127+
notifier_task = tg.create_task(notifier.connect())
124128
await notifier.wait_ready()
125129

126130
options = RoomOptions(webhook_url=WEBHOOK_URL)
127131
room = room_api.create_room(options=options)
128132

129133
peer, token = room_api.create_peer(room.id)
130134
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
131-
tg.create_task(peer_socket.connect(token))
135+
peer_socket_task = tg.create_task(peer_socket.connect(token))
132136

133137
await peer_socket.wait_ready()
134138

@@ -137,6 +141,9 @@ async def test_peer_connected_disconnected(
137141

138142
await assert_task
139143

144+
notifier_task.cancel()
145+
peer_socket_task.cancel()
146+
140147
for event in event_checks:
141148
self.assert_event(event)
142149

@@ -155,22 +162,25 @@ async def test_peer_connected_room_deleted(
155162
async with asyncio.TaskGroup() as tg:
156163
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))
157164

158-
tg.create_task(notifier.connect())
165+
notifier_task = tg.create_task(notifier.connect())
159166
await notifier.wait_ready()
160167

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

165172
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
166-
tg.create_task(peer_socket.connect(token))
173+
peer_socket_task = tg.create_task(peer_socket.connect(token))
167174

168175
await peer_socket.wait_ready()
169176

170177
room_api.delete_room(room.id)
171178

172179
await assert_task
173180

181+
notifier_task.cancel()
182+
peer_socket_task.cancel()
183+
174184
for event in event_checks:
175185
self.assert_event(event)
176186

0 commit comments

Comments
 (0)