2
2
from pytest import mark
3
3
4
4
from tirith .core .core import final_evaluator
5
-
5
+ from tirith . core . core import start_policy_evaluation_from_dict
6
6
7
7
@mark .passing
8
8
def test_final_evaluator_skipped_check_should_be_removed ():
@@ -38,3 +38,56 @@ def test_final_evaluator_malicious_eval_should_err():
38
38
"!skipped_check && passing_check || [].__class__.__base__" , dict (skipped_check = None , passing_check = True )
39
39
)
40
40
assert actual_result == (False , ["The following symbols are not allowed: __class__, __base__" ])
41
+
42
+
43
+ @mark .passing
44
+ def test_start_policy_evaluation_with_required_provider ():
45
+ policy_dict = {
46
+ "meta" : {"version" : "1.0" , "required_provider" : "legacy_provider" },
47
+ "evaluators" : [],
48
+ "eval_expression" : "True" ,
49
+ }
50
+ input_dict = {}
51
+
52
+ result = start_policy_evaluation_from_dict (policy_dict , input_dict )
53
+
54
+ assert result ["meta" ]["provider" ] == "legacy_provider"
55
+
56
+ @mark .passing
57
+ def test_start_policy_evaluation_with_provider ():
58
+ policy_dict = {
59
+ "meta" : {"version" : "1.0" , "provider" : "new_provider" },
60
+ "evaluators" : [],
61
+ "eval_expression" : "True" ,
62
+ }
63
+ input_dict = {}
64
+
65
+ result = start_policy_evaluation_from_dict (policy_dict , input_dict )
66
+
67
+ assert result ["meta" ]["provider" ] == "new_provider"
68
+
69
+ @mark .passing
70
+ def test_start_policy_evaluation_with_both_providers ():
71
+ policy_dict = {
72
+ "meta" : {"version" : "1.0" , "provider" : "new_provider" , "required_provider" : "legacy_provider" },
73
+ "evaluators" : [],
74
+ "eval_expression" : "True" ,
75
+ }
76
+ input_dict = {}
77
+
78
+ result = start_policy_evaluation_from_dict (policy_dict , input_dict )
79
+
80
+ assert result ["meta" ]["provider" ] == "new_provider"
81
+
82
+ @mark .passing
83
+ def test_start_policy_evaluation_with_neither_provider ():
84
+ policy_dict = {
85
+ "meta" : {"version" : "1.0" },
86
+ "evaluators" : [],
87
+ "eval_expression" : "True" ,
88
+ }
89
+ input_dict = {}
90
+
91
+ result = start_policy_evaluation_from_dict (policy_dict , input_dict )
92
+
93
+ assert result ["meta" ]["provider" ] == "core"
0 commit comments