@@ -54,6 +54,58 @@ def test_pipeline():
5454 mock_step_2 .assert_called_once ()
5555 mock_step_3 .assert_called_once ()
5656
57+ def test_pipeline_completion_using_step_decorator ():
58+ """
59+ Test that the pipeline runs all the steps in the correct order,
60+ using the step decorator instead of the step function.
61+ """
62+ mock_step_1 = Mock ()
63+ mock_step_2 = Mock ()
64+ mock_step_3 = Mock ()
65+
66+ mock_step_1 .return_value = "step 1"
67+ mock_step_2 .return_value = "step 2"
68+ mock_step_3 .return_value = "step 3"
69+
70+ @step (
71+ name = "step_one" ,
72+ description = "Step one" ,
73+ version = "1.0.0" ,
74+ )
75+ def step_one ():
76+ mock_step_1 ()
77+
78+ @step (
79+ name = "step_two" ,
80+ description = "Step two" ,
81+ version = "1.0.0" ,
82+ )
83+ def step_two ():
84+ mock_step_2 ()
85+
86+ @step (
87+ name = "step_three" ,
88+ description = "Step three" ,
89+ version = "1.0.0" ,
90+ )
91+ def step_three ():
92+ mock_step_3 ()
93+
94+ @pipeline (
95+ name = "test_pipeline" ,
96+ description = "Test pipeline" ,
97+ version = "1.0.0" ,
98+ )
99+ def test_pipeline ():
100+ return [step_one , step_two , step_three ]
101+
102+ pipe = test_pipeline ()
103+ pipe .run ()
104+
105+ assert len (pipe .steps ) == 3
106+ mock_step_1 .assert_called_once ()
107+ mock_step_2 .assert_called_once ()
108+ mock_step_3 .assert_called_once ()
57109
58110def test_pipeline_failure_no_function_passed ():
59111 """
@@ -97,7 +149,8 @@ def test_pipeline():
97149 pipe .run ()
98150
99151 assert (
100- "Not a valid step. Consider using the step() method to create steps for your pipeline."
152+ "Not a valid step. Consider using the step decorator to "
153+ "create steps for your pipeline."
101154 == str (context .value )
102155 )
103156
@@ -145,7 +198,8 @@ def test_pipeline():
145198
146199def test_pipeline_failure_exception_in_step ():
147200 """
148- Test that the pipeline fails with an Exception if there is an exception in one of the steps.
201+ Test that the pipeline fails with an Exception if there is an exception
202+ in one of the steps.
149203
150204 Also check that the error message is correct.
151205 """
0 commit comments