99from pctasks .core .utils .template import (
1010 LocalTemplater ,
1111 TemplateError ,
12+ TemplateValue ,
1213 find_value ,
1314 split_path ,
1415 template_dict ,
@@ -37,9 +38,10 @@ def test_template() -> None:
3738 },
3839 }
3940
40- def _get_value (path : List [str ]) -> Optional [str ]:
41+ def _get_value (path : List [str ]) -> Optional [TemplateValue ]:
4142 if path [0 ] == "params" :
4243 return find_value (params , path [1 :])
44+ return None
4345
4446 result = template_dict (data , _get_value )
4547
@@ -49,7 +51,36 @@ def _get_value(path: List[str]) -> Optional[str]:
4951 assert result ["environment" ]["list" ] == "two"
5052
5153
52- def test_split_path ():
54+ def test_template_new_types () -> None :
55+ params = {
56+ "force" : True ,
57+ "int_value" : 1 ,
58+ "float_value" : 1.0 ,
59+ }
60+
61+ data = {
62+ "id" : "something" ,
63+ "environment" : {
64+ "force" : r"${{ params.force }}" ,
65+ "int_value" : r"${{ params.int_value }}" ,
66+ "float_value" : r"${{ params.float_value }}" ,
67+ },
68+ }
69+
70+ def _get_value (path : List [str ]) -> Optional [TemplateValue ]:
71+ if path [0 ] == "params" :
72+ return find_value (params , path [1 :])
73+ return None
74+
75+ result = template_dict (data , _get_value )
76+
77+ assert result ["id" ] == "something"
78+ assert result ["environment" ]["force" ]
79+ assert result ["environment" ]["int_value" ] == 1
80+ assert result ["environment" ]["float_value" ] == 1.0
81+
82+
83+ def test_split_path () -> None :
5384 s = "a.b.c"
5485 assert split_path (s ) == ["a" , "b" , "c" ]
5586
@@ -79,7 +110,7 @@ def _get_value(path: List[str]) -> Optional[str]:
79110 templated_collection .validate ()
80111
81112
82- def test_local_path_template_glob (tmp_path ) -> None :
113+ def test_local_path_template_glob (tmp_path : pathlib . Path ) -> None :
83114 p = tmp_path .joinpath ("file-1.json" )
84115
85116 yaml_str = f"""
0 commit comments