Description
Several important code paths have no test coverage:
1. _notify_overlay with callback — bot/bot.py
_make_bot() uses object.__new__ and never sets _on_state_change, so the overlay notification path is always short-circuited in tests.
Tests to add:
test_notify_overlay_calls_callback_when_set() — verify callback is awaited with a dict containing "status"
test_notify_overlay_no_op_when_callback_not_set() — must not raise
2. start_game error branches — bot/bot.py
FileNotFoundError when the word-list file is missing
- Empty word list (
"Word list is empty" path)
Tests to add:
async def test_start_word_list_not_found_sends_error():
with patch("bot.bot.load_word_list", side_effect=FileNotFoundError):
await _start_fn(bot, ctx)
assert "not found" in ctx.send.call_args[0][0].lower()
async def test_start_empty_word_list_sends_error():
with patch("bot.bot.load_word_list", return_value=[]):
await _start_fn(bot, ctx)
assert "empty" in ctx.send.call_args[0][0].lower()
3. WebSocket dead-client cleanup — overlay/server.py
The except Exception branch in broadcast() that removes a disconnected client is never hit by any test.
Test to add:
async def test_broadcast_removes_dead_client():
server = OverlayServer()
dead_ws = AsyncMock(spec=WebSocket)
dead_ws.send_text = AsyncMock(side_effect=Exception("gone"))
server._clients.add(dead_ws)
await server.broadcast({"status": "idle"})
assert dead_ws not in server._clients
4. guess with a word exceeding _MAX_WORD_LEN
No test covers the len(word) > _MAX_WORD_LEN validation branch.
Identified by
🧪 [Tech] Tester
Description
Several important code paths have no test coverage:
1.
_notify_overlaywith callback —bot/bot.py_make_bot()usesobject.__new__and never sets_on_state_change, so the overlay notification path is always short-circuited in tests.Tests to add:
test_notify_overlay_calls_callback_when_set()— verify callback is awaited with a dict containing"status"test_notify_overlay_no_op_when_callback_not_set()— must not raise2.
start_gameerror branches —bot/bot.pyFileNotFoundErrorwhen the word-list file is missing"Word list is empty"path)Tests to add:
3. WebSocket dead-client cleanup —
overlay/server.pyThe
except Exceptionbranch inbroadcast()that removes a disconnected client is never hit by any test.Test to add:
4.
guesswith a word exceeding_MAX_WORD_LENNo test covers the
len(word) > _MAX_WORD_LENvalidation branch.Identified by
🧪
[Tech] Tester