FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: characterization tests for payload_utils assistant predicates by WilliamBergamin · Pull Request #1548 · slackapi/bolt-python · GitHub

test: characterization tests for payload_utils assistant predicates - #1548

Merged
WilliamBergamin merged 2 commits into
mainfrom
add-payload-utils-tests
Jul 8, 2026
Merged

test: characterization tests for payload_utils assistant predicates#1548
WilliamBergamin merged 2 commits into
mainfrom
add-payload-utils-tests

Conversation

WilliamBergamin commented Jul 7, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

Adds unit tests characterizing the existing assistant-thread payload predicates in slack_bolt/request/payload_utils.py, plus small fixture improvements the tests rely on.

Testing

./scripts/run_tests.sh tests/slack_bolt/request/test_payload_utils.py
./scripts/run_tests.sh tests/scenario_tests/test_events_assistant.py tests/scenario_tests/test_events_ignore_self.py
./scripts/run_tests.sh tests/scenario_tests_async/test_events_assistant.py tests/scenario_tests_async/test_events_ignore_self.py

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

Add unit tests for the existing assistant-thread payload predicates in
slack_bolt/request/payload_utils.py (is_event, the user/bot/other message
predicates, and is_assistant_event and thread predicates). These tests
characterize current behavior and pass against main as-is.

Also improve the shared scenario fixtures they rely on:
- test_events_assistant: use a C-prefixed channel id for the channel
  (non-im) message fixtures to match their channel_type
- test_events_ignore_self: add channel_type to the reaction item

Extracted from the set_suggested_prompts refactor branch so this
regression net can land on main first.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

codecov Bot commented Jul 7, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.44%. Comparing base (12c2da5) to head (a0509b4).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1548      +/-   ##
==========================================
+ Coverage   91.37%   91.44%   +0.06%     
==========================================
  Files         228      228              
  Lines        7285     7285              
==========================================
+ Hits         6657     6662       +5     
+ Misses        628      623       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

WilliamBergamin added a commit that referenced this pull request Jul 7, 2026
The characterization tests for the pre-existing assistant predicates,
and the shared scenario fixture improvements, were moved to a separate
branch (PR #1548) so they can land on main first as a regression net.

This branch now keeps only the tests for behavior it introduces: the
new is_message_event, is_any_im_message_event, and is_im_message_event
predicates.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin self-assigned this Jul 8, 2026
WilliamBergamin requested review from mwbrooks and zimeg July 8, 2026 16:13
WilliamBergamin marked this pull request as ready for review July 8, 2026 16:13
WilliamBergamin requested a review from a team as a code owner July 8, 2026 16:13

zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@WilliamBergamin LGTM! Thanks for keeping coverage confident with ongoing changes. I left one question about fixtures but think this is good to go when the time is right 🚢 💨

"user_profile": {},
"thread_ts": "1726133698.626339",
"parent_user_id": "W222",
"channel": "D111",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🤖 question: Is keeping this prefixed with D meaningful to the assistant feature or is channel_user_message_event_body intended to be more generic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

From the documentation the channel should start with a C, thats the only reason for the change 🙏

Comment on lines +114 to +139
def test_is_event(self):
positives = {
"thread_started": thread_started_event_body,
"thread_context_changed": thread_context_changed_event_body,
"user_message_im": user_message_event_body,
"user_message_im_with_assistant_thread": user_message_event_body_with_assistant_thread,
"message_changed_im": message_changed_event_body,
"channel_user_message": channel_user_message_event_body,
"channel_message_changed": channel_message_changed_event_body,
"bot_message_channel": bot_message_event_payload,
"classic_bot_message_channel": classic_bot_message_event_payload,
"message_deleted_channel": message_deleted_channel_body,
"reaction_added": reaction_added_event_body,
"file_share_im": file_share_im_message_body,
"bot_im_thread": bot_im_thread_message_body,
"im_no_thread_ts": im_message_no_thread_ts_body,
}
negatives = {
"block_actions": block_actions_body,
"slash_command": slash_command_body,
"empty_dict": {},
}
for key, body in positives.items():
assert is_event(body), f"{key} should be recognized as an event"
for key, body in negatives.items():
assert not is_event(body), f"{key} should NOT be recognized as an event"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🌟 praise: Fun test to see I think!

WilliamBergamin merged commit 8fbd503 into main Jul 8, 2026
16 checks passed
WilliamBergamin deleted the add-payload-utils-tests branch July 8, 2026 19:23

mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

✅ Everything passes locally and this looks great. Thanks for adding these test @WilliamBergamin 🙇🏻

"thread_ts": "1726133698.626339",
"parent_user_id": "W222",
"channel": "D111",
"channel": "C111",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

praise: Thanks for updating this!

"type": "message",
"channel": "C111",
"ts": "1599529504.000400",
"channel_type": "channel",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👌🏻

from tests.scenario_tests.test_events_ignore_self import event_body as reaction_added_event_body
from tests.scenario_tests.test_block_actions import body as block_actions_body

file_share_im_message_body = build_payload(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

praise: These are super valuable new fixtures to add.

for key, body in negatives.items():
assert not is_event(body), f"{key} should NOT be recognized as an event"

def test_is_user_message_event_in_assistant_thread(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

note: Nice to see a separate assistant thread test

WilliamBergamin added a commit that referenced this pull request Jul 8, 2026
Reunites this branch with PR #1548 (assistant predicate characterization
tests + shared scenario fixtures), which was split out to land on main
first. Resolved the add/add conflict in test_payload_utils.py by taking
the union: this branch's new-behavior tests (is_message_event,
is_any_im_message_event, is_im_message_event) plus the assistant-predicate
characterization tests from #1548.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL