Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakekaplan committed Dec 10, 2024
1 parent 42d0159 commit df7c3d9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/prefect/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import pendulum
import pytest
from starlette.status import WS_1008_POLICY_VIOLATION
from websockets.asyncio.server import Server as WebSocketServer
from websockets.asyncio.server import ServerConnection as WebSocketServerConnection
from websockets.asyncio.server import serve as websocket_serve
from websockets.exceptions import ConnectionClosed
from websockets.legacy.server import WebSocketServer, WebSocketServerProtocol, serve

from prefect.events import Event
from prefect.events.clients import (
Expand Down Expand Up @@ -291,7 +293,7 @@ async def events_server(
) -> AsyncGenerator[WebSocketServer, None]:
server: WebSocketServer

async def handler(socket: WebSocketServerProtocol) -> None:
async def handler(socket: WebSocketServerConnection) -> None:
path = socket.path
recorder.connections += 1
if puppeteer.refuse_any_further_connections:
Expand All @@ -304,7 +306,7 @@ async def handler(socket: WebSocketServerProtocol) -> None:
elif path.endswith("/events/out"):
await outgoing_events(socket)

async def incoming_events(socket: WebSocketServerProtocol):
async def incoming_events(socket: WebSocketServerConnection):
while True:
try:
message = await socket.recv()
Expand All @@ -317,7 +319,7 @@ async def incoming_events(socket: WebSocketServerProtocol):
if puppeteer.hard_disconnect_after == event.id:
raise ValueError("zonk")

async def outgoing_events(socket: WebSocketServerProtocol):
async def outgoing_events(socket: WebSocketServerConnection):
# 1. authentication
auth_message = json.loads(await socket.recv())

Expand Down Expand Up @@ -352,7 +354,9 @@ async def outgoing_events(socket: WebSocketServerProtocol):
puppeteer.hard_disconnect_after = None
raise ValueError("zonk")

async with serve(handler, host="localhost", port=unused_tcp_port) as server:
async with websocket_serve(
handler, host="localhost", port=unused_tcp_port
) as server:
yield server


Expand Down

0 comments on commit df7c3d9

Please sign in to comment.