Skip to content

Commit

Permalink
Merge branch 'main' into releases/4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Tracy Boehrer committed Jan 26, 2024
2 parents 5cb6949 + 489d547 commit f3e1228
Show file tree
Hide file tree
Showing 13 changed files with 1,123 additions and 419 deletions.
908 changes: 503 additions & 405 deletions .pylintrc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def test_logger(self):
)

def test_thrower(self):
"""Tests that unhandled exceptions generate an exception telemetry item parented to the request telemetry item"""
"""
Tests that unhandled exceptions generate an exception telemetry item parented to the request telemetry item
"""
response = self.invoke_post("thrower")
self.assertEqual(response.status_code, 500)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def send_activities(
)
)

response = response or ResourceResponse(activity.id or "")
response = response or ResourceResponse(id=activity.id or "")

responses.append(response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from aiohttp.web import (
middleware,
HTTPException,
HTTPNotImplemented,
HTTPUnauthorized,
HTTPNotFound,
Expand All @@ -27,6 +28,8 @@ async def aiohttp_error_middleware(request, handler):
raise HTTPUnauthorized()
except KeyError:
raise HTTPNotFound()
except HTTPException:
raise
except Exception:
traceback.print_exc()
raise HTTPInternalServerError()
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
2 changes: 1 addition & 1 deletion libraries/botbuilder-core/tests/simple_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def update_activity(self, context: TurnContext, activity: Activity):
if self._call_on_update is not None:
self._call_on_update(activity)

return ResourceResponse(activity.id)
return ResourceResponse(id=activity.id)

async def process_request(self, activity, handler):
context = TurnContext(self, activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def update_activity(self, context: TurnContext, activity: Activity):
if self._call_on_update is not None:
self._call_on_update(activity)

return ResourceResponse(activity.id)
return ResourceResponse(id=activity.id)

async def process_request(self, activity, handler):
context = TurnContext(self, activity)
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(

def dispose(self):
if self._session:
asyncio.create_task(self._session.close())
task = asyncio.create_task(self._session.close())

async def close(self, close_status: WebSocketCloseStatus, status_description: str):
await self._aiohttp_ws.close(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def retrieve_aiohttp_body():
@middleware
async def bot_telemetry_middleware(request, handler):
"""Process the incoming Flask request."""
if "application/json" in request.headers["Content-Type"]:
if "Content-Type" in request.headers and request.headers["Content-Type"] == "application/json":
body = await request.json()
_REQUEST_BODIES[current_thread().ident] = body

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def _on_receive_response(self, identifier: UUID, response: ReceiveResponse

def _on_cancel_stream(self, content_stream_assembler: PayloadStreamAssembler):
# TODO: on original C# code content_stream_assembler is typed as IAssembler
asyncio.create_task(
task = asyncio.create_task(
self._send_operations.send_cancel_stream(
content_stream_assembler.identifier
)
Expand Down
Loading

0 comments on commit f3e1228

Please sign in to comment.