@@ -141,3 +141,37 @@ def test_json_progress_indicator(mocker):
141
141
mocker .call ("Starting Pipeline" ),
142
142
mocker .call ("Pipeline Completed" ),
143
143
]
144
+
145
+
146
+ def test_json_progress_indicator_on_fatal_error (mocker ):
147
+ indicator = JsonProgressIndicator (mocker .Mock (), "pipeline_name" )
148
+ indicator .logger .error = mocker .Mock ()
149
+ exception = Exception ("Boom" )
150
+ indicator .on_fatal_error (exception )
151
+ indicator .logger .error .assert_called_once_with (
152
+ "Pipeline Failed" , exc_info = exception
153
+ )
154
+
155
+
156
+ def test_json_progress_indicator_on_progress (mocker ):
157
+ indicator = JsonProgressIndicator (mocker .Mock (), "pipeline_name" )
158
+ indicator .logger .info = mocker .Mock ()
159
+ indicator .progress_callback (1000 , Metrics ())
160
+ indicator .logger .info .assert_called_once_with (
161
+ "Processing Record" , extra = {"index" : 1000 }
162
+ )
163
+
164
+
165
+ def test_json_progress_indicator_on_finish_with_exception (mocker ):
166
+ indicator = JsonProgressIndicator (mocker .Mock (), "pipeline_name" )
167
+ indicator .logger .info = mocker .Mock ()
168
+ indicator .logger .error = mocker .Mock ()
169
+ exception = Exception ("Boom" )
170
+ indicator .on_fatal_error (exception )
171
+ with pytest .raises (Exception ):
172
+ indicator .on_finish (Metrics ())
173
+ indicator .logger .error .assert_called_once_with (
174
+ "Pipeline Failed" , exc_info = exception
175
+ )
176
+ indicator .logger .info .assert_called_once_with ("Pipeline Completed" )
177
+ assert indicator .exception is exception
0 commit comments