From 00d8dcfc2f1dd128f566934a9204259c14798f24 Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Tue, 26 Jan 2021 12:03:03 -0800 Subject: [PATCH] Adding add-upgrade and remove-upgrade activity types in ActivityHandler --- .../botbuilder/core/activity_handler.py | 4 +-- .../tests/test_activity_handler.py | 34 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libraries/botbuilder-core/botbuilder/core/activity_handler.py b/libraries/botbuilder-core/botbuilder/core/activity_handler.py index c5afb5e08..28c924e0f 100644 --- a/libraries/botbuilder-core/botbuilder/core/activity_handler.py +++ b/libraries/botbuilder-core/botbuilder/core/activity_handler.py @@ -381,9 +381,9 @@ async def on_installation_update( # pylint: disable=unused-argument :type turn_context: :class:`botbuilder.core.TurnContext` :returns: A task that represents the work queued to execute """ - if turn_context.activity.action == "add": + if turn_context.activity.action in ("add", "add-upgrade"): return await self.on_installation_update_add(turn_context) - if turn_context.activity.action == "remove": + if turn_context.activity.action in ("remove", "remove-upgrade"): return await self.on_installation_update_remove(turn_context) return diff --git a/libraries/botbuilder-core/tests/test_activity_handler.py b/libraries/botbuilder-core/tests/test_activity_handler.py index 2f8b0daea..69ccfa830 100644 --- a/libraries/botbuilder-core/tests/test_activity_handler.py +++ b/libraries/botbuilder-core/tests/test_activity_handler.py @@ -268,7 +268,23 @@ async def test_on_installation_update_add(self): assert bot.record[0] == "on_installation_update" assert bot.record[1] == "on_installation_update_add" - async def test_on_installation_update_add_remove(self): + async def test_on_installation_update_add_upgrade(self): + activity = Activity( + type=ActivityTypes.installation_update, action="add-upgrade" + ) + + adapter = TestInvokeAdapter() + turn_context = TurnContext(adapter, activity) + + # Act + bot = TestingActivityHandler() + await bot.on_turn(turn_context) + + assert len(bot.record) == 2 + assert bot.record[0] == "on_installation_update" + assert bot.record[1] == "on_installation_update_add" + + async def test_on_installation_update_remove(self): activity = Activity(type=ActivityTypes.installation_update, action="remove") adapter = TestInvokeAdapter() @@ -282,6 +298,22 @@ async def test_on_installation_update_add_remove(self): assert bot.record[0] == "on_installation_update" assert bot.record[1] == "on_installation_update_remove" + async def test_on_installation_update_remove_upgrade(self): + activity = Activity( + type=ActivityTypes.installation_update, action="remove-upgrade" + ) + + adapter = TestInvokeAdapter() + turn_context = TurnContext(adapter, activity) + + # Act + bot = TestingActivityHandler() + await bot.on_turn(turn_context) + + assert len(bot.record) == 2 + assert bot.record[0] == "on_installation_update" + assert bot.record[1] == "on_installation_update_remove" + async def test_healthcheck(self): activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)