10000 Deprecate HealthCheck Activity (#1702) · jayryanj/botbuilder-python@06f5054 · GitHub
[go: up one dir, main page]

Skip to content

Commit 06f5054

Browse files
MartinLuccanerasantgr11ceciliaavila
authored
Deprecate HealthCheck Activity (microsoft#1702)
Co-authored-by: Santiago Grangetto <santiago.grangetto@southworks.com> Co-authored-by: Cecilia Avila <44245136+ceciliaavila@users.noreply.github.com>
1 parent 09a9c80 commit 06f5054

File tree

7 files changed

+1
-159
lines changed

7 files changed

+1
-159
lines changed

libraries/botbuilder-core/botbuilder/core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from .user_state import UserState
4646
from .register_class_middleware import RegisterClassMiddleware
4747
from .adapter_extensions import AdapterExtensions
48-
from .healthcheck import HealthCheck
4948

5049
__all__ = [
5150
"ActivityHandler",
@@ -68,7 +67,6 @@
6867
"ConversationState",
6968
"conversation_reference_extension",
7069
"ExtendedUserTokenProvider",
71-
"HealthCheck",
7270
"IntentScore",
7371
"InvokeResponse",
7472
"MemoryStorage",

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

Copy file name to clipboard
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111
ChannelAccount,
1212
MessageReaction,
1313
SignInConstants,
14-
HealthCheckResponse,
1514
)
1615

1716
from .bot import Bot
18-
from .bot_adapter import BotAdapter
19-
from .healthcheck import HealthCheck
2017
from .serializer_helper import serializer_helper
2118
from .bot_framework_adapter import BotFrameworkAdapter
2219
from .invoke_response import InvokeResponse
@@ -463,11 +460,6 @@ async def on_invoke_activity( # pylint: disable=unused-argument
463460
await self.on_adaptive_card_invoke(turn_context, invoke_value)
464461
)
465462

466-
if turn_context.activity.name == "healthcheck":
467-
return self._create_invoke_response(
468-
await self.on_healthcheck(turn_context)
469-
)
470-
471463
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
472464
except _InvokeResponseException as invoke_exception:
473465
return invoke_exception.create_invoke_response()
@@ -488,21 +480,6 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
488480
"""
489481
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
490482

491-
async def on_healthcheck(self, turn_context: TurnContext) -> HealthCheckResponse:
492-
"""
493-
Invoked when the bot is sent a health check from the hosting infrastructure or, in the case of
494-
Skills the parent bot. By default, this method acknowledges the health state of the bot.
495-
496-
When the on_invoke_activity method receives an Invoke with a Activity.name of `healthCheck`, it
497-
calls this method.
498-
499-
:param turn_context: A context object for this turn.
500-
:return: The HealthCheckResponse object
501-
"""
502-
return HealthCheck.create_healthcheck_response(
503-
turn_context.turn_state.get(BotAdapter.BOT_CONNECTOR_CLIENT_KEY)
504-
)
505-
506483
async def on_adaptive_card_invoke(
507484
self, turn_context: TurnContext, invoke_value: AdaptiveCardInvokeValue
508485
) -> AdaptiveCardInvokeResponse:

libraries/botbuilder-core/botbuilder/core/healthcheck.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

libraries/botbuilder-core/tests/test_activity_handler.py

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
from botframework.connector import ConnectorClient
66
from botframework.connector.auth import AppCredentials
77

8-
from botbuilder.core import ActivityHandler, BotAdapter, TurnContext, InvokeResponse
8+
from botbuilder.core import ActivityHandler, BotAdapter, TurnContext
99
from botbuilder.schema import (
1010
Activity,
1111
ActivityTypes,
1212
ChannelAccount,
1313
ConversationReference,
1414
MessageReaction,
1515
ResourceResponse,
16-
HealthCheckResponse,
1716
)
1817

19-
from botbuilder.core.bot_framework_adapter import USER_AGENT
20-
2118

2219
class TestingActivityHandler(ActivityHandler):
2320
__test__ = False
@@ -102,10 +99,6 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
10299
self.record.append("on_sign_in_invoke")
103100
return
104101

105-
async def on_healthcheck(self, turn_context: TurnContext) -> HealthCheckResponse:
106-
self.record.append("on_healthcheck")
107-
return HealthCheckResponse()
108-
109102

110103
class NotImplementedAdapter(BotAdapter):
111104
async def delete_activity(
@@ -313,46 +306,3 @@ async def test_on_installation_update_remove_upgrade(self):
313306
assert len(bot.record) == 2
314307
assert bot.record[0] == "on_installation_update"
315308
assert bot.record[1] == "on_installation_update_remove"
316-
317-
async def test_healthcheck(self):
318-
activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)
319-
320-
adapter = TestInvokeAdapter()
321-
turn_context = TurnContext(adapter, activity)
322-
323-
bot = ActivityHandler()
324-
await bot.on_turn(turn_context)
325-
326-
self.assertIsNotNone(adapter.activity)
327-
self.assertIsInstance(adapter.activity.value, InvokeResponse)
328-
self.assertEqual(adapter.activity.value.status, 200)
329-
330-
response = HealthCheckResponse.deserialize(adapter.activity.value.body)
331-
self.assertTrue(response.health_results.success)
332-
self.assertTrue(response.health_results.messages)
333-
self.assertEqual(response.health_results.messages[0], "Health check succeeded.")
334-
335-
async def test_healthcheck_with_connector(self):
336-
activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)
337-
338-
adapter = TestInvokeAdapter()
339-
turn_context = TurnContext(adapter, activity)
340-
341-
mock_connector_client = MockConnectorClient()
342-
turn_context.turn_state[
343-
BotAdapter.BOT_CONNECTOR_CLIENT_KEY
344-
] = mock_connector_client
345-
346-
bot = ActivityHandler()
347-
await bot.on_turn(turn_context)
348-
349-
self.assertIsNotNone(adapter.activity)
350-
self.assertIsInstance(adapter.activity.value, InvokeResponse)
351-
self.assertEqual(adapter.activity.value.status, 200)
352-
353-
response = HealthCheckResponse.deserialize(adapter.activity.value.body)
354-
self.assertTrue(response.health_results.success)
355-
self.assertEqual(response.health_results.authorization, "Bearer awesome")
356-
self.assertEqual(response.health_results.user_agent, USER_AGENT)
357-
self.assertTrue(response.health_results.messages)
358-
self.assertEqual(response.health_results.messages[0], "Health check succeeded.")

libraries/botbuilder-schema/botbuilder/schema/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272

7373
from ._sign_in_enums import SignInConstants
7474
from .callerid_constants import CallerIdConstants
75-
from .health_results import HealthResults
76-
from .healthcheck_response import HealthCheckResponse
7775
from .speech_constants import SpeechConstants
7876

7977
__all__ = [
@@ -146,7 +144,5 @@
146144
"ContactRelationUpdateActionTypes",
147145
"InstallationUpdateActionTypes",
148146
"CallerIdConstants",
149-
"HealthResults",
150-
"HealthCheckResponse",
151147
"SpeechConstants",
152148
]

libraries/botbuilder-schema/botbuilder/schema/health_results.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

libraries/botbuilder-schema/botbuilder/schema/healthcheck_response.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0