Skip to content

Missing tests: _notify_overlay callback, start_game error paths, WebSocket dead-client cleanup #58

@FlorentPoinsaut

Description

@FlorentPoinsaut

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority — noticeable but not blockingtestingTest coverage and quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions