1515 CorrectnessParams ,
1616 JsonPathRuleParam ,
1717)
18- from giskard_hub .types .check import (
19- _IDENTIFIER_TO_KIND ,
20- _check_param_to_spec ,
21- _check_params_to_api ,
22- _extract_check_params ,
18+ from giskard_hub .types .check import _extract_check_params
19+ from giskard_hub . resources . _check_helpers import (
20+ IDENTIFIER_TO_KIND ,
21+ check_param_to_spec ,
22+ check_params_to_specs ,
2323)
2424
2525# ---------------------------------------------------------------------------
2828
2929
3030def test_identifier_to_kind_mapping () -> None :
31- assert _IDENTIFIER_TO_KIND == {
31+ assert IDENTIFIER_TO_KIND == {
3232 "correctness" : "hub_correctness" ,
3333 "conformity" : "hub_conformity" ,
3434 "groundedness" : "hub_groundedness" ,
@@ -39,27 +39,27 @@ def test_identifier_to_kind_mapping() -> None:
3939
4040
4141def test_check_param_to_spec_prefers_params_type_over_identifier () -> None :
42- spec = _check_param_to_spec ("custom_name" , {"type" : "conformity" , "rules" : ["r" ]})
42+ spec = check_param_to_spec ("custom_name" , {"type" : "conformity" , "rules" : ["r" ]})
4343 assert spec == {"kind" : "hub_conformity" , "rules" : ["r" ]}
4444
4545
4646def test_check_param_to_spec_falls_back_to_identifier () -> None :
47- spec = _check_param_to_spec ("correctness" , {"reference" : "x" })
47+ spec = check_param_to_spec ("correctness" , {"reference" : "x" })
4848 assert spec == {"kind" : "hub_correctness" , "reference" : "x" }
4949
5050
5151def test_check_param_to_spec_passes_through_unknown_kind () -> None :
52- spec = _check_param_to_spec ("future_kind" , {"foo" : 1 })
52+ spec = check_param_to_spec ("future_kind" , {"foo" : 1 })
5353 assert spec == {"kind" : "future_kind" , "foo" : 1 }
5454
5555
5656def test_check_param_to_spec_raises_when_no_kind_derivable () -> None :
5757 with pytest .raises (ValueError , match = "Cannot derive check kind" ):
58- _check_param_to_spec (None , {"reference" : "x" })
58+ check_param_to_spec (None , {"reference" : "x" })
5959
6060
6161def test_check_param_to_spec_accepts_basemodel () -> None :
62- spec = _check_param_to_spec ("correctness" , CorrectnessParams (reference = "x" ))
62+ spec = check_param_to_spec ("correctness" , CorrectnessParams (reference = "x" ))
6363 assert spec == {"kind" : "hub_correctness" , "reference" : "x" }
6464
6565
@@ -73,8 +73,8 @@ def test_extract_check_params_empty_when_no_spec() -> None:
7373 assert _extract_check_params ({"spec" : None }) == {}
7474
7575
76- def test_check_params_to_api_emits_spec_with_kind () -> None :
77- api = _check_params_to_api ([{"identifier" : "correctness" , "params" : {"reference" : "x" }}])
76+ def test_check_params_to_specs_emits_nested_with_kind () -> None :
77+ api = check_params_to_specs ([{"identifier" : "correctness" , "params" : {"reference" : "x" }}])
7878 assert api == [
7979 {
8080 "identifier" : "correctness" ,
@@ -84,13 +84,13 @@ def test_check_params_to_api_emits_spec_with_kind() -> None:
8484 ]
8585
8686
87- def test_check_params_to_api_omits_spec_when_no_params () -> None :
88- api = _check_params_to_api ([{"identifier" : "tone_pro_xyz" }])
87+ def test_check_params_to_specs_omits_spec_when_no_params () -> None :
88+ api = check_params_to_specs ([{"identifier" : "tone_pro_xyz" }])
8989 assert api == [{"identifier" : "tone_pro_xyz" , "enabled" : True }]
9090
9191
92- def test_check_params_to_api_strips_redundant_type () -> None :
93- api = _check_params_to_api ([{"identifier" : "string_match" , "params" : {"type" : "string_match" , "keyword" : "k" }}])
92+ def test_check_params_to_specs_strips_redundant_type () -> None :
93+ api = check_params_to_specs ([{"identifier" : "string_match" , "params" : {"type" : "string_match" , "keyword" : "k" }}])
9494 assert api == [
9595 {
9696 "identifier" : "string_match" ,
0 commit comments