Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libraries/botbuilder-core/botbuilder/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from .user_state import UserState
from .register_class_middleware import RegisterClassMiddleware
from .adapter_extensions import AdapterExtensions
from .healthcheck import HealthCheck

__all__ = [
"ActivityHandler",
Expand All @@ -68,7 +67,6 @@
"ConversationState",
"conversation_reference_extension",
"ExtendedUserTokenProvider",
"HealthCheck",
"IntentScore",
"InvokeResponse",
"MemoryStorage",
Expand Down
23 changes: 0 additions & 23 deletions libraries/botbuilder-core/botbuilder/core/activity_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
ChannelAccount,
MessageReaction,
SignInConstants,
HealthCheckResponse,
)

from .bot import Bot
from .bot_adapter import BotAdapter
from .healthcheck import HealthCheck
from .serializer_helper import serializer_helper
from .bot_framework_adapter import BotFrameworkAdapter
from .invoke_response import InvokeResponse
Expand Down Expand Up @@ -463,11 +460,6 @@ async def on_invoke_activity( # pylint: disable=unused-argument
await self.on_adaptive_card_invoke(turn_context, invoke_value)
)

if turn_context.activity.name == "healthcheck":
return self._create_invoke_response(
await self.on_healthcheck(turn_context)
)

raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
except _InvokeResponseException as invoke_exception:
return invoke_exception.create_invoke_response()
Expand All @@ -488,21 +480,6 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
"""
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)

async def on_healthcheck(self, turn_context: TurnContext) -> HealthCheckResponse:
"""
Invoked when the bot is sent a health check from the hosting infrastructure or, in the case of
Skills the parent bot. By default, this method acknowledges the health state of the bot.

When the on_invoke_activity method receives an Invoke with a Activity.name of `healthCheck`, it
calls this method.

:param turn_context: A context object for this turn.
:return: The HealthCheckResponse object
"""
return HealthCheck.create_healthcheck_response(
turn_context.turn_state.get(BotAdapter.BOT_CONNECTOR_CLIENT_KEY)
)

async def on_adaptive_card_invoke(
self, turn_context: TurnContext, invoke_value: AdaptiveCardInvokeValue
) -> AdaptiveCardInvokeResponse:
Expand Down
31 changes: 0 additions & 31 deletions libraries/botbuilder-core/botbuilder/core/healthcheck.py

This file was deleted.

52 changes: 1 addition & 51 deletions libraries/botbuilder-core/tests/test_activity_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
from botframework.connector import ConnectorClient
from botframework.connector.auth import AppCredentials

from botbuilder.core import ActivityHandler, BotAdapter, TurnContext, InvokeResponse
from botbuilder.core import ActivityHandler, BotAdapter, TurnContext
from botbuilder.schema import (
Activity,
ActivityTypes,
ChannelAccount,
ConversationReference,
MessageReaction,
ResourceResponse,
HealthCheckResponse,
)

from botbuilder.core.bot_framework_adapter import USER_AGENT


class TestingActivityHandler(ActivityHandler):
__test__ = False
Expand Down Expand Up @@ -102,10 +99,6 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument
self.record.append("on_sign_in_invoke")
return

async def on_healthcheck(self, turn_context: TurnContext) -> HealthCheckResponse:
self.record.append("on_healthcheck")
return HealthCheckResponse()


class NotImplementedAdapter(BotAdapter):
async def delete_activity(
Expand Down Expand Up @@ -313,46 +306,3 @@ async def test_on_installation_update_remove_upgrade(self):
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",)

adapter = TestInvokeAdapter()
turn_context = TurnContext(adapter, activity)

bot = ActivityHandler()
await bot.on_turn(turn_context)

self.assertIsNotNone(adapter.activity)
self.assertIsInstance(adapter.activity.value, InvokeResponse)
self.assertEqual(adapter.activity.value.status, 200)

response = HealthCheckResponse.deserialize(adapter.activity.value.body)
self.assertTrue(response.health_results.success)
self.assertTrue(response.health_results.messages)
self.assertEqual(response.health_results.messages[0], "Health check succeeded.")

async def test_healthcheck_with_connector(self):
activity = Activity(type=ActivityTypes.invoke, name="healthcheck",)

adapter = TestInvokeAdapter()
turn_context = TurnContext(adapter, activity)

mock_connector_client = MockConnectorClient()
turn_context.turn_state[
BotAdapter.BOT_CONNECTOR_CLIENT_KEY
] = mock_connector_client

bot = ActivityHandler()
await bot.on_turn(turn_context)

self.assertIsNotNone(adapter.activity)
self.assertIsInstance(adapter.activity.value, InvokeResponse)
self.assertEqual(adapter.activity.value.status, 200)

response = HealthCheckResponse.deserialize(adapter.activity.value.body)
self.assertTrue(response.health_results.success)
self.assertEqual(response.health_results.authorization, "Bearer awesome")
self.assertEqual(response.health_results.user_agent, USER_AGENT)
self.assertTrue(response.health_results.messages)
self.assertEqual(response.health_results.messages[0], "Health check succeeded.")
4 changes: 0 additions & 4 deletions libraries/botbuilder-schema/botbuilder/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@

from ._sign_in_enums import SignInConstants
from .callerid_constants import CallerIdConstants
from .health_results import HealthResults
from .healthcheck_response import HealthCheckResponse
from .speech_constants import SpeechConstants

__all__ = [
Expand Down Expand Up @@ -146,7 +144,5 @@
"ContactRelationUpdateActionTypes",
"InstallationUpdateActionTypes",
"CallerIdConstants",
"HealthResults",
"HealthCheckResponse",
"SpeechConstants",
]
32 changes: 0 additions & 32 deletions libraries/botbuilder-schema/botbuilder/schema/health_results.py

This file was deleted.

This file was deleted.