def create_skill_definition(skill: SkillDefinition): if skill.group.lower() == ("echo"): skill_definition = ObjectPath.assign(EchoSkill(), skill) elif skill.group.lower() == ("waterfall"): skill_definition = ObjectPath.assign(WaterfallSkill(), skill) elif skill.group.lower() == ("teams"): skill_definition = ObjectPath.assign(TeamsSkill(), skill) else: raise Exception(f"Unable to find definition class for {skill.id}.") return skill_definition
async def test_typed_no_overlay(self): default_options = Options( last_name="Smith", first_name="Fred", age=22, location=Location( lat=1.2312312, long=3.234234, ), ) result = ObjectPath.assign(default_options, None) assert result.last_name == default_options.last_name assert result.first_name == default_options.first_name assert result.age == default_options.age assert result.boolean == default_options.boolean assert result.location.lat == default_options.location.lat assert result.location.long == default_options.location.long
async def test_typed_no_target(self): overlay = Options( last_name="Smith", first_name="Fred", age=22, location=Location( lat=1.2312312, long=3.234234, ), ) result = ObjectPath.assign(None, overlay) assert result.last_name == overlay.last_name assert result.first_name == overlay.first_name assert result.age == overlay.age assert result.boolean == overlay.boolean assert result.location.lat == overlay.location.lat assert result.location.long == overlay.location.long
async def test_dict_partial_overlay(self): default_options = { "last_name": "Smith", "first_name": "Fred", "age": 22, "location": Location( lat=1.2312312, long=3.234234, ), } overlay = { "last_name": "Grant", } result = ObjectPath.assign(default_options, overlay) assert result["last_name"] == overlay["last_name"] assert result["first_name"] == default_options["first_name"] assert result["age"] == default_options["age"] assert result["location"].lat == default_options["location"].lat assert result["location"].long == default_options["location"].long
async def test_typed_full_overlay(self): default_options = Options( last_name="Smith", first_name="Fred", age=22, location=Location( lat=1.2312312, long=3.234234, ), dictionary={ "one": 1, "two": 2 }, ) overlay = Options( last_name="Grant", first_name="Eddit", age=32, location=Location( lat=2.2312312, long=2.234234, ), dictionary={ "one": 99, "three": 3 }, ) result = ObjectPath.assign(default_options, overlay) assert result.last_name == overlay.last_name assert result.first_name == overlay.first_name assert result.age == overlay.age assert result.boolean == overlay.boolean assert result.location.lat == overlay.location.lat assert result.location.long == overlay.location.long assert "one" in result.dictionary assert result.dictionary["one"] == 99 assert "two" in result.dictionary assert "three" in result.dictionary
async def begin_dialog( self, dialog_context: DialogContext, options: object = None ) -> DialogTurnResult: """ Called when the dialog is started and pushed onto the dialog stack. .. remarks: If the task is successful, the result indicates whether the dialog is still active after the turn has been processed by the dialog. :param dialog_context: The :class:'botbuilder.dialogs.DialogContext' for the current turn of conversation. :param options: Optional, initial information to pass to the dialog. """ if not dialog_context: raise TypeError("DialogContext is required") if ( dialog_context.context and dialog_context.context.activity and dialog_context.context.activity.type != ActivityTypes.message ): return Dialog.end_of_turn dialog_options = QnAMakerDialogOptions( options=self._get_qnamaker_options(dialog_context), response_options=self._get_qna_response_options(dialog_context), ) if options: dialog_options = ObjectPath.assign(dialog_options, options) ObjectPath.set_path_value( dialog_context.active_dialog.state, QnAMakerDialog.KEY_OPTIONS, dialog_options, ) return await super().begin_dialog(dialog_context, dialog_options)
async def test_dict_to_typed_overlay(self): default_options = Options( last_name="Smith", first_name="Fred", age=22, location=Location( lat=1.2312312, long=3.234234, ), ) overlay = { "last_name": "Grant", } result = ObjectPath.assign(default_options, overlay) assert result.last_name == overlay["last_name"] assert result.first_name == default_options.first_name assert result.age == default_options.age assert result.boolean == default_options.boolean assert result.location.lat == default_options.location.lat assert result.location.long == default_options.location.long
async def test_no_target_or_overlay(self): result = ObjectPath.assign(None, None, Options) assert result