Skip to content

Commit

Permalink
Ensure Connector Client is retrieved in teams_info.py (#2062)
Browse files Browse the repository at this point in the history
* Ensure Connector Client is retrieved in teams_info.py

* Revert changes in cloud_adapter.py

* Ensure Connector Client is retrieved in teams_info.py

* Fixed teams member added test with mock ConnectorClient

---------

Co-authored-by: tracyboehrer <tracyboehrer@users.noreply.github.com>
  • Loading branch information
infinite-ram and tracyboehrer authored Jan 26, 2024
1 parent 7a03e65 commit 489d547
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 489d547

Please sign in to comment.