17
17
18
18
from stepfunctions .inputs import ExecutionInput , StepInput , StepResult
19
19
20
- def test_placeholder_creation_with_subscript_operator ():
21
- step_input = StepInput ()
22
- placeholder_variable = step_input ["A" ]
20
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
21
+ def test_placeholder_creation_with_subscript_operator ( placeholder ):
22
+ placeholder_variable = placeholder ["A" ]
23
23
assert placeholder_variable .name == "A"
24
24
assert placeholder_variable .type is None
25
25
26
- def test_placeholder_creation_with_type ():
27
- workflow_input = ExecutionInput ()
28
- placeholder_variable = workflow_input ["A" ]["b" ].get ("C" , float )
26
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
27
+ def test_placeholder_creation_with_type ( placeholder ):
28
+ placeholder_variable = placeholder ["A" ]["b" ].get ("C" , float )
29
29
assert placeholder_variable .name == "C"
30
30
assert placeholder_variable .type == float
31
31
32
- def test_placeholder_creation_with_int_key ():
33
- workflow_input = ExecutionInput ()
34
- placeholder_variable = workflow_input ["A" ][0 ]
32
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
33
+ def test_placeholder_creation_with_int_key ( placeholder ):
34
+ placeholder_variable = placeholder ["A" ][0 ]
35
35
assert placeholder_variable .name == 0
36
36
assert placeholder_variable .type == None
37
37
38
- def test_placeholder_creation_with_invalid_key ():
39
- step_input = StepInput ()
38
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
39
+ def test_placeholder_creation_with_invalid_key ( placeholder ):
40
40
with pytest .raises (ValueError ):
41
- step_input ["A" ][1.3 ]
41
+ placeholder ["A" ][1.3 ]
42
42
with pytest .raises (ValueError ):
43
- step_input ["A" ].get (1.2 , str )
43
+ placeholder ["A" ].get (1.2 , str )
44
44
45
- def test_placeholder_creation_failure_with_type ():
46
- workflow_input = ExecutionInput ()
47
- placeholder_variable = workflow_input ["A" ]["b" ].get ("C" , float )
45
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
46
+ def test_placeholder_creation_failure_with_type ( placeholder ):
47
+ placeholder_variable = placeholder ["A" ]["b" ].get ("C" , float )
48
48
with pytest .raises (ValueError ):
49
- workflow_input ["A" ]["b" ].get ("C" , int )
49
+ placeholder ["A" ]["b" ].get ("C" , int )
50
50
51
- def test_placeholder_path ():
52
- workflow_input = ExecutionInput ()
53
- placeholder_variable = workflow_input ["A" ]["b" ]["C" ]
51
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
52
+ def test_placeholder_path ( placeholder ):
53
+ placeholder_variable = placeholder ["A" ]["b" ]["C" ]
54
54
expected_path = ["A" , "b" , "C" ]
55
55
assert placeholder_variable ._get_path () == expected_path
56
56
57
- def test_placeholder_contains ():
58
- step_input = StepInput ()
59
- var_one = step_input ["Key01" ]
60
- var_two = step_input ["Key02" ]["Key03" ]
61
- var_three = step_input ["Key01" ]["Key04" ]
62
- var_four = step_input ["Key05" ]
57
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
58
+ def test_placeholder_contains ( placeholder ):
59
+ var_one = placeholder ["Key01" ]
60
+ var_two = placeholder ["Key02" ]["Key03" ]
61
+ var_three = placeholder ["Key01" ]["Key04" ]
62
+ var_four = placeholder ["Key05" ]
63
63
64
- step_input_two = StepInput ()
65
- var_five = step_input_two ["Key07" ]
64
+ placeholder_two = StepInput ()
65
+ var_five = placeholder_two ["Key07" ]
66
66
67
- assert step_input .contains (var_three ) == True
68
- assert step_input .contains (var_five ) == False
69
- assert step_input_two .contains (var_three ) == False
67
+ assert placeholder .contains (var_three ) == True
68
+ assert placeholder .contains (var_five ) == False
69
+ assert placeholder_two .contains (var_three ) == False
70
70
71
- def test_placeholder_schema_as_dict ():
72
- workflow_input = ExecutionInput ()
73
- workflow_input ["A" ]["b" ].get ("C" , float )
74
- workflow_input ["Message" ]
75
- workflow_input ["Key01" ]["Key02" ]
76
- workflow_input ["Key03" ]
77
- workflow_input ["Key03" ]["Key04" ]
71
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
72
+ def test_placeholder_schema_as_dict ( placeholder ):
73
+ placeholder ["A" ]["b" ].get ("C" , float )
74
+ placeholder ["Message" ]
75
+ placeholder ["Key01" ]["Key02" ]
76
+ placeholder ["Key03" ]
77
+ placeholder ["Key03" ]["Key04" ]
78
78
79
79
expected_schema = {
80
80
"A" : {
@@ -91,14 +91,14 @@ def test_placeholder_schema_as_dict():
91
91
}
92
92
}
93
93
94
- assert workflow_input .get_schema_as_dict () == expected_schema
94
+ assert placeholder .get_schema_as_dict () == expected_schema
95
95
96
- def test_placeholder_schema_as_json ():
97
- step_input = StepInput ()
98
- step_input ["Response" ].get ("StatusCode" , int )
99
- step_input ["Hello" ]["World" ]
100
- step_input ["A" ]
101
- step_input ["Hello" ]["World" ].get ("Test" , str )
96
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
97
+ def test_placeholder_schema_as_json ( placeholder ):
98
+ placeholder ["Response" ].get ("StatusCode" , int )
99
+ placeholder ["Hello" ]["World" ]
100
+ placeholder ["A" ]
101
+ placeholder ["Hello" ]["World" ].get ("Test" , str )
102
102
103
103
expected_schema = {
104
104
"Response" : {
@@ -112,29 +112,27 @@ def test_placeholder_schema_as_json():
112
112
"A" : "str"
113
113
}
114
114
115
- assert step_input .get_schema_as_json () == json .dumps (expected_schema )
115
+ assert placeholder .get_schema_as_json () == json .dumps (expected_schema )
116
116
117
- def test_placeholder_is_empty ():
118
- workflow_input = ExecutionInput ()
119
- placeholder_variable = workflow_input ["A" ]["B" ]["C" ]
117
+ @ pytest . mark . parametrize ( "placeholder" , [ StepInput (), StepResult (), ExecutionInput ()])
118
+ def test_placeholder_is_empty ( placeholder ):
119
+ placeholder_variable = placeholder ["A" ]["B" ]["C" ]
120
120
assert placeholder_variable ._is_empty () == True
121
- workflow_input ["A" ]["B" ]["C" ]["D" ]
121
+ placeholder ["A" ]["B" ]["C" ]["D" ]
122
122
assert placeholder_variable ._is_empty () == False
123
123
124
+ @pytest .mark .parametrize ("placeholder" , [StepInput (), StepResult (), ExecutionInput ()])
125
+ def test_placeholder_make_immutable (placeholder ):
126
+ placeholder ["A" ]["b" ].get ("C" , float )
127
+ placeholder ["Message" ]
128
+ placeholder ["Key01" ]["Key02" ]
129
+ placeholder ["Key03" ]
130
+ placeholder ["Key03" ]["Key04" ]
124
131
125
- def test_placeholder_make_immutable ():
126
- workflow_input = ExecutionInput ()
127
- workflow_input ["A" ]["b" ].get ("C" , float )
128
- workflow_input ["Message" ]
129
- workflow_input ["Key01" ]["Key02" ]
130
- workflow_input ["Key03" ]
131
- workflow_input ["Key03" ]["Key04" ]
132
-
133
- assert check_immutable (workflow_input ) == False
134
-
135
- workflow_input ._make_immutable ()
136
- assert check_immutable (workflow_input ) == True
132
+ assert check_immutable (placeholder ) == False
137
133
134
+ placeholder ._make_immutable ()
135
+ assert check_immutable (placeholder ) == True
138
136
139
137
def test_placeholder_with_schema ():
140
138
test_schema = {
@@ -168,6 +166,11 @@ def test_step_input_jsonpath():
168
166
placeholder_variable = step_input ["A" ]["b" ].get (0 , float )
169
167
assert placeholder_variable .to_jsonpath () == "$['A']['b'][0]"
170
168
169
+ def test_step_result_jsonpath ():
170
+ step_result = StepResult ()
171
+ placeholder_variable = step_result ["A" ]["b" ].get (0 , float )
172
+ assert placeholder_variable .to_jsonpath () == "$['A']['b'][0]"
173
+
171
174
# UTILS
172
175
173
176
def check_immutable (placeholder ):
0 commit comments