@@ -43,7 +43,7 @@ def encoded_frame_json(encoded_frame_binary):
4343def test_websocket_camera_init_default ():
4444 """Test WebSocketCamera initialization with default parameters."""
4545 camera = WebSocketCamera ()
46- assert camera .address == "ws://0.0.0.0:8080"
46+ assert camera .url == "ws://0.0.0.0:8080"
4747 assert camera .port == 8080
4848 assert camera .timeout == 3
4949 assert camera .frame_format == "binary"
@@ -55,7 +55,7 @@ def test_websocket_camera_init_default():
5555def test_websocket_camera_init_custom ():
5656 """Test WebSocketCamera initialization with custom parameters."""
5757 camera = WebSocketCamera (port = 9090 , timeout = 30 , frame_format = "json" , resolution = (1920 , 1080 ), fps = 30 )
58- assert camera .address == "ws://0.0.0.0:9090" # No env var is set, so uses default host
58+ assert camera .url == "ws://0.0.0.0:9090" # No env var is set, so uses default host
5959 assert camera .port == 9090
6060 assert camera .timeout == 30
6161 assert camera .frame_format == "json"
@@ -167,7 +167,7 @@ def test_websocket_camera_read_frame_empty_queue():
167167async def test_websocket_camera_capture_frame (encoded_frame_binary ):
168168 """Test capturing frame from WebSocket camera."""
169169 with WebSocketCamera (port = 0 , frame_format = "binary" ) as camera :
170- async with websockets .connect (camera .address ) as ws :
170+ async with websockets .connect (camera .url ) as ws :
171171 # Skip welcome message
172172 await ws .recv ()
173173
@@ -189,15 +189,15 @@ async def test_websocket_camera_single_client():
189189
190190 try :
191191 # Connect first client
192- async with websockets .connect (camera .address ) as ws1 :
192+ async with websockets .connect (camera .url ) as ws1 :
193193 # First client should receive welcome message
194194 welcome = await ws1 .recv ()
195195 message = json .loads (welcome )
196196 assert message ["status" ] == "connected"
197197
198198 # Try to connect second client while first is connected
199199 try :
200- async with websockets .connect (camera .address ) as ws2 :
200+ async with websockets .connect (camera .url ) as ws2 :
201201 # Second client should receive rejection message
202202 rejection = await asyncio .wait_for (ws2 .recv (), timeout = 1.0 )
203203 message = json .loads (rejection )
@@ -213,7 +213,7 @@ async def test_websocket_camera_single_client():
213213async def test_websocket_camera_welcome_message ():
214214 """Test that welcome message is sent to connected client."""
215215 with WebSocketCamera (port = 0 ) as camera :
216- async with websockets .connect (camera .address ) as ws :
216+ async with websockets .connect (camera .url ) as ws :
217217 # Should receive welcome message
218218 welcome = await asyncio .wait_for (ws .recv (), timeout = 1.0 )
219219 message = json .loads (welcome )
@@ -226,7 +226,7 @@ async def test_websocket_camera_welcome_message():
226226async def test_websocket_camera_receives_frames (encoded_frame_binary ):
227227 """Test that server receives and queues frames from client."""
228228 with WebSocketCamera (port = 0 , frame_format = "binary" ) as camera :
229- async with websockets .connect (camera .address ) as ws :
229+ async with websockets .connect (camera .url ) as ws :
230230 # Skip welcome message
231231 await ws .recv ()
232232
@@ -247,7 +247,7 @@ async def test_websocket_camera_disconnects_client_on_stop():
247247 camera .start ()
248248
249249 try :
250- async with websockets .connect (camera .address ) as ws :
250+ async with websockets .connect (camera .url ) as ws :
251251 # Client connected, receive welcome message
252252 welcome = await ws .recv ()
253253 message = json .loads (welcome )
@@ -286,7 +286,7 @@ def test_websocket_camera_stop_without_client():
286286async def test_websocket_camera_backpressure (sample_frame ):
287287 """Test that old frames are dropped when new frames arrive faster than they're consumed."""
288288 with WebSocketCamera (port = 0 , frame_format = "binary" ) as camera :
289- async with websockets .connect (camera .address ) as ws :
289+ async with websockets .connect (camera .url ) as ws :
290290 await ws .recv () # Skip welcome message
291291
292292 _ , buffer1 = cv2 .imencode (".jpg" , np .ones ((480 , 640 , 3 ), dtype = np .uint8 ) * 1 )
@@ -318,6 +318,7 @@ def adjustment(frame):
318318
319319 # Capture uses adjustments
320320 frame = camera .capture ()
321+ assert frame is not None
321322
322323 # The adjustment is applied in capture()
323324 expected = sample_frame + 50
@@ -355,7 +356,7 @@ def event_listener(event_type, data):
355356
356357 # This should emit connection and disconnection events
357358 async def client_task ():
358- async with websockets .connect (camera .address ):
359+ async with websockets .connect (camera .url ):
359360 pass
360361
361362 # Run client concurrently to properly test event handling
@@ -438,7 +439,7 @@ def event_listener(event_type, data):
438439
439440 # This should emit a connection event but no disconnection event
440441 async def client_task ():
441- async with websockets .connect (camera .address ):
442+ async with websockets .connect (camera .url ):
442443 pass
443444 await can_close .wait ()
444445
0 commit comments