async def on_teams_members_added_dispatch_activity(  # pylint: disable=unused-argument
        self,
        members_added: [ChannelAccount],
        team_info: TeamInfo,
        turn_context: TurnContext,
    ):

        team_members = {}
        team_members_added = []
        for member in members_added:
            if member.additional_properties != {}:
                team_members_added.append(
                    deserializer_helper(TeamsChannelAccount, member)
                )
            else:
                if team_members == {}:
                    result = await TeamsInfo.get_members(turn_context)
                    team_members = {i.id: i for i in result}

                if member.id in team_members:
                    team_members_added.append(member)
                else:
                    new_teams_channel_account = TeamsChannelAccount(
                        id=member.id,
                        name=member.name,
                        aad_object_id=member.aad_object_id,
                        role=member.role,
                    )
                    team_members_added.append(new_teams_channel_account)

        return await self.on_teams_members_added_activity(
            team_members_added, team_info, turn_context
        )
    def test_teams_helper_teams_schema(self):
        # Arrange
        data = {
            "data": {
                "key": "value"
            },
            "context": {
                "theme": "dark"
            },
            "commandId": "test_command",
            "commandContext": "command_context_test",
            "botMessagePreviewAction": "edit",
            "botActivityPreview": [{
                "id": "activity123"
            }],
            "messagePayload": {
                "id": "payloadid"
            },
        }

        # Act
        result = deserializer_helper(MessagingExtensionAction, data)

        # Assert
        assert result.data == {"key": "value"}
        assert result.context == TaskModuleRequestContext(theme="dark")
        assert result.command_id == "test_command"
        assert result.bot_message_preview_action == "edit"
        assert len(result.bot_activity_preview) == 1
        assert result.bot_activity_preview[0] == Activity(id="activity123")
        assert result.message_payload == MessageActionsPayload(id="payloadid")
    def test_teams_helper_schema(self):
        # Arrange
        data = {
            "mentioned": {
                "id": "123",
                "name": "testName"
            },
            "text": "Hello <at>testName</at>",
            "type": "mention",
        }

        # Act
        result = deserializer_helper(Mention, data)

        # Assert
        assert result.mentioned == ChannelAccount(id="123", name="testName")
        assert result.text == "Hello <at>testName</at>"
        assert result.type == "mention"
    async def on_invoke_activity(self, turn_context: TurnContext):
        try:
            if (
                not turn_context.activity.name
                and turn_context.activity.channel_id == Channels.ms_teams
            ):
                return await self.on_teams_card_action_invoke_activity(turn_context)

            if turn_context.activity.name == "signin/verifyState":
                await self.on_teams_signin_verify_state(turn_context)
                return self._create_invoke_response()

            if turn_context.activity.name == "fileConsent/invoke":
                return await self.on_teams_file_consent(
                    turn_context,
                    deserializer_helper(
                        FileConsentCardResponse, turn_context.activity.value
                    ),
                )

            if turn_context.activity.name == "actionableMessage/executeAction":
                await self.on_teams_o365_connector_card_action(
                    turn_context,
                    deserializer_helper(
                        O365ConnectorCardActionQuery, turn_context.activity.value
                    ),
                )
                return self._create_invoke_response()

            if turn_context.activity.name == "composeExtension/queryLink":
                return self._create_invoke_response(
                    await self.on_teams_app_based_link_query(
                        turn_context,
                        deserializer_helper(
                            AppBasedLinkQuery, turn_context.activity.value
                        ),
                    )
                )

            if turn_context.activity.name == "composeExtension/query":
                return self._create_invoke_response(
                    await self.on_teams_messaging_extension_query(
                        turn_context,
                        deserializer_helper(
                            MessagingExtensionQuery, turn_context.activity.value
                        ),
                    )
                )

            if turn_context.activity.name == "composeExtension/selectItem":
                return self._create_invoke_response(
                    await self.on_teams_messaging_extension_select_item(
                        turn_context, turn_context.activity.value
                    )
                )

            if turn_context.activity.name == "composeExtension/submitAction":
                return self._create_invoke_response(
                    await self.on_teams_messaging_extension_submit_action_dispatch(
                        turn_context,
                        deserializer_helper(
                            MessagingExtensionAction, turn_context.activity.value
                        ),
                    )
                )

            if turn_context.activity.name == "composeExtension/fetchTask":
                return self._create_invoke_response(
                    await self.on_teams_messaging_extension_fetch_task(
                        turn_context,
                        deserializer_helper(
                            MessagingExtensionAction, turn_context.activity.value,
                        ),
                    )
                )

            if turn_context.activity.name == "composeExtension/querySettingUrl":
                return self._create_invoke_response(
                    await self.on_teams_messaging_extension_configuration_query_settings_url(
                        turn_context,
                        deserializer_helper(
                            MessagingExtensionQuery, turn_context.activity.value
                        ),
                    )
                )

            if turn_context.activity.name == "composeExtension/setting":
                await self.on_teams_messaging_extension_configuration_setting(
                    turn_context, turn_context.activity.value
                )
                return self._create_invoke_response()

            if turn_context.activity.name == "composeExtension/onCardButtonClicked":
                await self.on_teams_messaging_extension_card_button_clicked(
                    turn_context, turn_context.activity.value
                )
                return self._create_invoke_response()

            if turn_context.activity.name == "task/fetch":
                return self._create_invoke_response(
                    await self.on_teams_task_module_fetch(
                        turn_context,
                        deserializer_helper(
                            TaskModuleRequest, turn_context.activity.value
                        ),
                    )
                )

            if turn_context.activity.name == "task/submit":
                return self._create_invoke_response(
                    await self.on_teams_task_module_submit(
                        turn_context,
                        deserializer_helper(
                            TaskModuleRequest, turn_context.activity.value
                        ),
                    )
                )

            raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
        except _InvokeResponseException as err:
            return err.create_invoke_response()