8000 Added InstallationUpdate Activity type handling (#1272) · snifhex/botbuilder-python@59dadd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59dadd0

Browse files
authored
Added InstallationUpdate Activity type handling (microsoft#1272)
1 parent ecaa4ed commit 59dadd0

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

libraries/botbuilder-core/botbuilder/core/activity_handler.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ async def on_turn(self, turn_context: TurnContext):
8686
await self.on_end_of_conversation_activity(turn_context)
8787
elif turn_context.activity.type == ActivityTypes.typing:
8888
await self.on_typing_activity(turn_context)
89+
elif turn_context.activity.type == ActivityTypes.installation_update:
90+
await self.on_installation_update(turn_context)
8991
else:
9092
await self.on_unrecognized_activity_type(turn_context)
9193

@@ -365,6 +367,19 @@ async def on_typing_activity( # pylint: disable=unused-argument
365367
"""
366368
return
367369

370+
async def on_installation_update( # pylint: disable=unused-argument
371+
self, turn_context: TurnContext
372+
):
373+
"""
374+
Override this in a derived class to provide logic specific to
375+
ActivityTypes.InstallationUpdate activities.
376+
377+
:param turn_context: The context object for this turn
378+
:type turn_context: :class:`botbuilder.core.TurnContext`
379+
:returns: A task that represents the work queued to execute
380+
"""
381+
return
382+
368383
async def on_unrecognized_activity_type( # pylint: disable=unused-argument
369384
self, turn_context: TurnContext
370385
):

libraries/botbuilder-core/tests/test_activity_handler.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ async def on_typing_activity(self, turn_context: TurnContext):
7373
self.record.append("on_typing_activity")
7474
return await super().on_typing_activity(turn_context)
7575

76+
async def on_installation_update(self, turn_context: TurnContext):
77+
self.record.append("on_installation_update")
78+
return await super().on_installation_update(turn_context)
79+
7680
async def on_unrecognized_activity_type(self, turn_context: TurnContext):
7781
self.record.append("on_unrecognized_activity_type")
7882
return await super().on_unrecognized_activity_type(turn_context)
@@ -229,6 +233,19 @@ async def test_typing_activity(self):
229233
assert len(bot.record) == 1
230234
assert bot.record[0] == "on_typing_activity"
231235

236+
async def test_on_installation_update(self):
237+
activity = Activity(type=ActivityTypes.installation_update)
238+
239+
adapter = TestInvokeAdapter()
240+
turn_context = TurnContext(adapter, activity)
241+
242+
# Act
243+
bot = TestingActivityHandler()
244+
await bot.on_turn(turn_context)
245+
246+
assert len(bot.record) == 1
247+
assert bot.record[0] == "on_installation_update"
248+
232249
async def test_healthcheck(self):
233250
activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)
234251

0 commit comments

Comments
 (0)
0