From 18df8a5ced5312e0efebb5ef13e3493e16868730 Mon Sep 17 00:00:00 2001 From: tracyboehrer Date: Thu, 23 Jul 2020 08:46:03 -0500 Subject: [PATCH] Added InstallationUpdate Activity type handling --- .../botbuilder/core/activity_handler.py | 15 +++++++++++++++ .../tests/test_activity_handler.py | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/libraries/botbuilder-core/botbuilder/core/activity_handler.py b/libraries/botbuilder-core/botbuilder/core/activity_handler.py index 0757ff28c..74515e709 100644 --- a/libraries/botbuilder-core/botbuilder/core/activity_handler.py +++ b/libraries/botbuilder-core/botbuilder/core/activity_handler.py @@ -86,6 +86,8 @@ async def on_turn(self, turn_context: TurnContext): await self.on_end_of_conversation_activity(turn_context) elif turn_context.activity.type == ActivityTypes.typing: await self.on_typing_activity(turn_context) + elif turn_context.activity.type == ActivityTypes.installation_update: + await self.on_installation_update(turn_context) else: await self.on_unrecognized_activity_type(turn_context) @@ -365,6 +367,19 @@ async def on_typing_activity( # pylint: disable=unused-argument """ return + async def on_installation_update( # pylint: disable=unused-argument + self, turn_context: TurnContext + ): + """ + Override this in a derived class to provide logic specific to + ActivityTypes.InstallationUpdate activities. + + :param turn_context: The context object for this turn + :type turn_context: :class:`botbuilder.core.TurnContext` + :returns: A task that represents the work queued to execute + """ + return + async def on_unrecognized_activity_type( # pylint: disable=unused-argument self, turn_context: TurnContext ): diff --git a/libraries/botbuilder-core/tests/test_activity_handler.py b/libraries/botbuilder-core/tests/test_activity_handler.py index d0f5b4f79..3cdd052f8 100644 --- a/libraries/botbuilder-core/tests/test_activity_handler.py +++ b/libraries/botbuilder-core/tests/test_activity_handler.py @@ -73,6 +73,10 @@ async def on_typing_activity(self, turn_context: TurnContext): self.record.append("on_typing_activity") return await super().on_typing_activity(turn_context) + async def on_installation_update(self, turn_context: TurnContext): + self.record.append("on_installation_update") + return await super().on_installation_update(turn_context) + async def on_unrecognized_activity_type(self, turn_context: TurnContext): self.record.append("on_unrecognized_activity_type") return await super().on_unrecognized_activity_type(turn_context) @@ -229,6 +233,19 @@ async def test_typing_activity(self): assert len(bot.record) == 1 assert bot.record[0] == "on_typing_activity" + async def test_on_installation_update(self): + activity = Activity(type=ActivityTypes.installation_update) + + adapter = TestInvokeAdapter() + turn_context = TurnContext(adapter, activity) + + # Act + bot = TestingActivityHandler() + await bot.on_turn(turn_context) + + assert len(bot.record) == 1 + assert bot.record[0] == "on_installation_update" + async def test_healthcheck(self): activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)