Skip to content

Ensure Connector Client is retrieved in teams_info.py #2062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions libraries/botbuilder-core/botbuilder/core/teams/teams_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
teams_get_meeting_info,
teams_get_channel_data,
)
from botbuilder.core import CloudAdapterBase, BotFrameworkAdapter, TurnContext
from botbuilder.core import CloudAdapterBase, BotFrameworkAdapter, TurnContext, BotAdapter
from botbuilder.schema import Activity, ConversationParameters, ConversationReference
from botbuilder.schema.teams import (
ChannelInfo,
Expand Down Expand Up @@ -318,10 +318,15 @@ def get_team_id(turn_context: TurnContext):

@staticmethod
async def _get_connector_client(turn_context: TurnContext) -> ConnectorClient:
return await turn_context.adapter.create_connector_client(
turn_context.activity.service_url
connector_client = turn_context.turn_state.get(
BotAdapter.BOT_CONNECTOR_CLIENT_KEY
)

if connector_client is None:
raise ValueError('This method requires a connector client.')

return connector_client

@staticmethod
async def _get_members(
connector_client: ConnectorClient, conversation_id: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ async def test_on_teams_members_added_activity(self):

turn_context = TurnContext(SimpleAdapter(), activity)

mock_connector_client = await SimpleAdapter.create_connector_client(self, turn_context.activity.service_url)
turn_context.turn_state[BotAdapter.BOT_CONNECTOR_CLIENT_KEY] = mock_connector_client

# Act
bot = TestingTeamsActivityHandler()
await bot.on_turn(turn_context)
Expand Down