File tree Expand file tree Collapse file tree
python/tests/unit/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -885,6 +885,40 @@ def test_function_model_dump_json(get_custom_type_function_pydantic):
885885 assert "metadata" in model_dump
886886
887887
888+ async def test_function_invoke_accepts_valid_typed_dict_argument (kernel : Kernel ):
889+ @kernel_function
890+ def typed_dict_function (value : dict [str , int ]) -> dict [str , int ]:
891+ return value
892+
893+ function = KernelFunction .from_method (typed_dict_function , "test" )
894+ result = await function .invoke (kernel = kernel , arguments = KernelArguments (value = {"first" : 1 , "second" : 2 }))
895+
896+ assert result .value == {"first" : 1 , "second" : 2 }
897+
898+
899+ async def test_function_invoke_rejects_invalid_typed_dict_argument (kernel : Kernel ):
900+ invoked = False
901+
902+ @kernel_function
903+ def typed_dict_function (value : dict [str , int ]) -> dict [str , int ]:
904+ nonlocal invoked
905+ invoked = True
906+ return value
907+
908+ function = KernelFunction .from_method (typed_dict_function , "test" )
909+
910+ with pytest .raises (
911+ FunctionExecutionException ,
912+ match = r"Parameter value is expected to be parsed to .* but is not\." ,
913+ ):
914+ await function .invoke (
915+ kernel = kernel ,
916+ arguments = KernelArguments (value = {"first" : "not-an-integer" }),
917+ )
918+
919+ assert not invoked
920+
921+
888922async def test_function_invoke_rejects_invalid_union_argument (kernel : Kernel ):
889923 invoked = False
890924
You can’t perform that action at this time.
0 commit comments