test(gateway/teams): patch TypingActivityInput on the loaded adapter module - #18979
Closed
Sanjays2402 wants to merge 1 commit into
Closed
test(gateway/teams): patch TypingActivityInput on the loaded adapter module#18979Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
…module
`TestTeamsSend::test_send_typing` was failing on `main` with:
AssertionError: Expected send to have been awaited once. Awaited 0 times.
Root cause: `TypingActivityInput` is conditionally imported from the
`microsoft_teams` SDK in `plugins/platforms/teams/adapter.py`. When
the SDK isn't installed in the test environment, the import block
falls through and `TypingActivityInput` is bound to `None`. The
adapter's `send_typing` then calls `TypingActivityInput()` \u2192 raises
`TypeError: 'NoneType' object is not callable` \u2192 swallowed by the
broad `except Exception: pass`. Net: `mock_app.send` is never awaited.
Patch in a callable stand-in so the call path under test actually
runs. The adapter is loaded under a mangled module name by
`load_plugin_adapter("teams")` (\u2192 `plugin_adapter_teams`), so target
the loaded module object directly via `patch.object(_teams_mod, ...)`
rather than the dotted `plugins.platforms.teams.adapter` path \u2014 which
is a *different* module instance and does not affect the one the test
actually exercises.
Re-confirmed:
$ pytest tests/gateway/test_teams.py -q
34 passed in 1.79s
No production code change. Fixes the failure observed on `main`
(run 25250051126):
`tests/gateway/test_teams.py::TestTeamsSend::test_send_typing`
Contributor
|
Thanks for chasing down the Teams typing-test failure. An automated hermes-sweeper review found that current Evidence:
Closing as implemented on main. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes one
Testsfailure observed onmain(and therefore propagating to every open PR):Reference run: 25250051126 on
5d3be898a.Root cause
TypingActivityInputis conditionally imported from themicrosoft_teamsSDK inplugins/platforms/teams/adapter.py:The Teams SDK isn't a tracked extra in
pyproject.toml(no[teams]extra, not in[messaging]either), so on a CI worker doinguv pip install -e ".[all,dev]"the SDK is absent →TypingActivityInput is None.send_typingthen does:…which raises
TypeError: 'NoneType' object is not callable, gets silently swallowed by the broadexcept, andmock_app.sendnever awaits.Why my first attempt didn't work
I initially tried
patch("plugins.platforms.teams.adapter.TypingActivityInput", ...), but the test loads the adapter via:…which gives the test a different module instance than
plugins.platforms.teams.adapter. Patching the dotted path patches the wrong module.Fix
patch.object(_teams_mod, "TypingActivityInput", ...)— patch the actual loaded module the test is exercising:Validation
Scope
sendawaited once, with the rightchat_id)Out of scope
The other ~11 main-CI failures — separate focused PRs (#18972, #18974, #18977 already up).