Repository: microsoft/botbuilder-python

Issue:
Add InstallationUpdate to ActivityHandler
See parent issue: https://github.com/microsoft/botframework-sdk/issues/5959


[enhancement]



Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-core/botbuilder/core/activity_handler.py b/libraries/botbuilder-core/botbuilder/core/activity_handler.py
--- 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
     ):


Test patch:
diff --git a/libraries/botbuilder-core/tests/test_activity_handler.py b/libraries/botbuilder-core/tests/test_activity_handler.py
--- 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",)