From 9685b5925e6ff883fbc26e20a198501382f1a16a Mon Sep 17 00:00:00 2001 From: David Gardner Date: Fri, 17 Jun 2022 14:33:28 -0700 Subject: [PATCH] Update the test_build_single to get coverage over the _build_single function --- tests/test_monitor_stage.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/test_monitor_stage.py b/tests/test_monitor_stage.py index 44efaa6d22..be7dff1944 100755 --- a/tests/test_monitor_stage.py +++ b/tests/test_monitor_stage.py @@ -87,9 +87,12 @@ def test_refresh(mock_morph_tqdm, config): mock_morph_tqdm.refresh.assert_called_once() +@mock.patch('morpheus.stages.general.monitor_stage.ops') @mock.patch('morpheus.stages.general.monitor_stage.MorpheusTqdm') -def test_build_single(mock_morph_tqdm, config): +def test_build_single(mock_morph_tqdm, mock_operators, config): + MonitorStage.stage_count = 0 mock_morph_tqdm.return_value = mock_morph_tqdm + mock_morph_tqdm.monitor = mock.MagicMock() mock_stream = mock.MagicMock() mock_segment = mock.MagicMock() @@ -100,18 +103,23 @@ def test_build_single(mock_morph_tqdm, config): m._build_single(mock_segment, mock_input) m.on_start() + assert MonitorStage.stage_count == 1 + mock_segment.make_node_full.assert_called_once() mock_segment.make_edge.assert_called_once() - # sink_on_error = mock_segment.make_node_full.call_args.args[2] - # sink_on_completed = mock_segment.make_sink.call_args.args[3] + node_fn = mock_segment.make_node_full.call_args.args[1] + + mock_observable = mock.MagicMock() + mock_subscriber = mock.MagicMock() - # # This is currenlty just a log stmt, just verify that its callable - # sink_on_error(RuntimeError("unittest")) + node_fn(mock_observable, mock_subscriber) + mock_operators.on_completed.assert_called_once() + sink_on_completed = mock_operators.on_completed.call_args.args[0] - # # Verify we close tqdm propperly on complete - # sink_on_completed() - # mock_morph_tqdm.stop.assert_called_once() + # Verify we close tqdm propperly on complete + sink_on_completed() + mock_morph_tqdm.stop.assert_called_once() def test_auto_count_fn(config):