Skip to content

Commit fd61e28

Browse files
JacobCoffeeclaude
andcommitted
test: fix WebSocket tests to use api_app fixture
All tests were using 'app' fixture which doesn't exist. Updated to use 'api_app' fixture from test fixtures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9a99927 commit fd61e28

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/unit/api/test_websocket.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def mock_db_session() -> AsyncMock:
2222
return AsyncMock(spec=AsyncSession)
2323

2424

25-
async def test_websocket_connection(app: Litestar) -> None:
25+
async def test_websocket_connection(api_app: Litestar) -> None:
2626
"""Test WebSocket connection and initial message reception."""
27-
async with AsyncTestClient(app=app) as client:
27+
async with AsyncTestClient(app=api_app) as client:
2828
ws = await client.websocket_connect("/ws/dashboard")
2929
# Receive first message
3030
data = await ws.receive_json()
@@ -48,9 +48,9 @@ async def test_websocket_connection(app: Litestar) -> None:
4848
ws.close()
4949

5050

51-
async def test_websocket_multiple_messages(app: Litestar) -> None:
51+
async def test_websocket_multiple_messages(api_app: Litestar) -> None:
5252
"""Test receiving multiple updates from WebSocket."""
53-
async with AsyncTestClient(app=app) as client:
53+
async with AsyncTestClient(app=api_app) as client:
5454
ws = await client.websocket_connect("/ws/dashboard")
5555
# Receive first message
5656
data1 = await ws.receive_json()
@@ -68,9 +68,9 @@ async def test_websocket_multiple_messages(app: Litestar) -> None:
6868
ws.close()
6969

7070

71-
async def test_websocket_server_count(app: Litestar) -> None:
71+
async def test_websocket_server_count(api_app: Litestar) -> None:
7272
"""Test that server count is returned correctly."""
73-
async with AsyncTestClient(app=app) as client:
73+
async with AsyncTestClient(app=api_app) as client:
7474
ws = await client.websocket_connect("/ws/dashboard")
7575
data = await ws.receive_json()
7676

@@ -80,9 +80,9 @@ async def test_websocket_server_count(app: Litestar) -> None:
8080
ws.close()
8181

8282

83-
async def test_websocket_bot_status(app: Litestar) -> None:
83+
async def test_websocket_bot_status(api_app: Litestar) -> None:
8484
"""Test that bot status is returned."""
85-
async with AsyncTestClient(app=app) as client:
85+
async with AsyncTestClient(app=api_app) as client:
8686
ws = await client.websocket_connect("/ws/dashboard")
8787
data = await ws.receive_json()
8888

@@ -92,9 +92,9 @@ async def test_websocket_bot_status(app: Litestar) -> None:
9292
ws.close()
9393

9494

95-
async def test_websocket_uptime_format(app: Litestar) -> None:
95+
async def test_websocket_uptime_format(api_app: Litestar) -> None:
9696
"""Test that uptime is in correct format (seconds)."""
97-
async with AsyncTestClient(app=app) as client:
97+
async with AsyncTestClient(app=api_app) as client:
9898
ws = await client.websocket_connect("/ws/dashboard")
9999
data = await ws.receive_json()
100100

@@ -157,12 +157,12 @@ async def test_set_startup_time() -> None:
157157

158158

159159
@patch("byte_api.domain.web.controllers.websocket.get_server_count")
160-
async def test_websocket_with_mocked_server_count(mock_get_server_count: AsyncMock, app: Litestar) -> None:
160+
async def test_websocket_with_mocked_server_count(mock_get_server_count: AsyncMock, api_app: Litestar) -> None:
161161
"""Test WebSocket with mocked server count."""
162162
# Mock server count to return specific value
163163
mock_get_server_count.return_value = 42
164164

165-
async with AsyncTestClient(app=app) as client:
165+
async with AsyncTestClient(app=api_app) as client:
166166
ws = await client.websocket_connect("/ws/dashboard")
167167
data = await ws.receive_json()
168168

0 commit comments

Comments
 (0)