Skip to content

Conversation

@joshishiv4
Copy link
Owner

tests: Add adapter-level tests for Merels via game_handler.

Mirror the style used by connect_four to exercise the GameAdapter
flow for Merels. Assert on stable fragments to avoid brittle failures
when wording changes.

Included:

  • “help” shows the Merels help block (checks for key commands).
  • “start game” posts an invite containing “wants to play”, “Merels”, “join”.
  • “join” after an invite surfaces the game’s start/help text (containment).
  • Light coverage of MerelsMessageHandler helpers:
    • parse_board identity
    • token mapping via get_player_color
    • alert_move_message formatting

Out of scope:

  • No production code changes.
  • No UI or bot behavior changes; tests only.

Rationale / approach:

  • Followed connect_four/test_connect_four.py structure (BotTestCase,
    transcript scanning) to test the adapter path users exercise in practice.
  • Used containment checks for help/start strings to reduce brittleness.

How did you test this PR?

  • Focused suite:
    pytest -q zulip_bots/zulip_bots/bots/merels/test_merels_adapter.py
    
  • Merels bot tests group:
    pytest -q zulip_bots/zulip_bots/bots/merels/test
    # (Observed: 36 passed locally)
    
  • Lint / types (per Zulip docs):
    ./tools/lint
    ./tools/run-mypy
    
    Both clean locally for the new test file.

Notes:

  • This change does not affect matrix bridge/integrations or require runtime
    configuration; it only adds tests under zulip_bots/.../merels/.

Fixes #433.


Recreated from zulip/python-zulip-api#891

⚠ This PR was MERGED upstream.
Merged at: 2025-12-16T23:50:53Z

Mirror the style used by connect_four to exercise the GameAdapter
flow for Merels. Use stable fragments to avoid brittleness.

Included:
- help shows Merels help
- start game posts an invite with “wants to play”, “Merels”, “join”
- join triggers start message (containment)
- light checks for MerelsMessageHandler helpers

No production changes; tests only.

Fixes #433.
Combine the adapter-flow tests with the existing Merels bot tests
to keep the suite cohesive, mirroring connect_four.
Replace brittle exact-string checks with stable substring assertions.
Remove obsolete FIXME/TODO notes.

No production code changes; tests only. All suites pass locally.

Fixes #433.
Merels previously had adapter-focused tests for help/start/join, but
the move path through GameAdapter was untested. This adds a small
in-file test helper to drive the adapter and a test that starts a
2-player game, sends a move, counts model.make_move calls, and asserts
that the bot replies. This covers the 'test lib for game_handler'
FIXME.

I did not add 'computer move' tests, because the Merels bot declares
supports_computer = False; there is no single-player/computer flow
to exercise. I left a comment in above TestMerelsAdapter that
clarifies this.

No production changes; tests only. Passes local pytest, mypy, and
lint.

Fixes #433.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants