Skip to content

Commit fad09d5

Browse files
committed
Improving coverage
1 parent afe9d6a commit fad09d5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/unit/cli/operations/test_run_pipeline.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,37 @@ def test_json_progress_indicator(mocker):
141141
mocker.call("Starting Pipeline"),
142142
mocker.call("Pipeline Completed"),
143143
]
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

tests/unit/test_metrics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ def test_prometheus_metric_handler_import_error(mocker):
136136
"The prometheus_client library is required to use the PrometheusMetricHandler."
137137
in str(excinfo.value)
138138
)
139+
140+
141+
def test_aggregate_handler_tick_calls_all_handlers(mocker):
142+
mock_handler1 = mocker.Mock()
143+
mock_handler2 = mocker.Mock()
144+
handler = AggregateHandler([mock_handler1, mock_handler2])
145+
handler.tick()
146+
mock_handler1.tick.assert_called_once()
147+
mock_handler2.tick.assert_called_once()

0 commit comments

Comments
 (0)