Working stage, added  test_start*.
@@ -1081,5 +1081,84 @@ class TestSendingProcess:
# Note
assert sp._config['north'] == expected_config['north']
+ def test_start_stream_not_valid(self, event_loop):
+ """ Unit tests - _start - stream_id is not valid """
+ with patch.object(asyncio, 'get_event_loop', return_value=event_loop):
+ sp = SendingProcess()
+
+ with patch.object(sp, '_is_stream_id_valid', return_value=False):
+ with patch.object(sp, '_plugin_load') as mocked_plugin_load:
+ result = sp._start(STREAM_ID)
+
+ assert not result
+ assert not mocked_plugin_load.called
+
+ def test_start_sp_disabled(self, event_loop):
+ """ Unit tests - _start - sending process is disabled """
+
+ with patch.object(asyncio, 'get_event_loop', return_value=event_loop):
+ sp = SendingProcess()
+
+ sp._plugin = MagicMock()
+ sp._config['enable'] = False
+ sp._config_from_manager = {}
+
+ with patch.object(sp, '_is_stream_id_valid', return_value=True):
+ with patch.object(sp, '_retrieve_configuration'):
+ with patch.object(sp, '_plugin_load') as mocked_plugin_load:
+ result = sp._start(STREAM_ID)
+
+ assert not result
+ assert not mocked_plugin_load.called
+
+ def test_start_not_north(self, event_loop):
+ """ Unit tests - _start - it is not a north plugin """
+ with patch.object(asyncio, 'get_event_loop', return_value=event_loop):
+ sp = SendingProcess()
+
+ sp._plugin = MagicMock()
+ sp._config['enable'] = True
+ sp._config_from_manager = {}
+
+ with patch.object(sp, '_is_stream_id_valid', return_value=True):
+ with patch.object(sp, '_retrieve_configuration'):
+ with patch.object(sp, '_plugin_load') as mocked_plugin_load:
+ with patch.object(sp._plugin, 'plugin_info') as mocked_plugin_info:
+ with patch.object(sp, '_is_north_valid', return_value=False) as mocked_is_north_valid:
+
+ result = sp._start(STREAM_ID)
+
+ assert not result
+ assert mocked_plugin_load.called
+ assert mocked_plugin_info.called
+ assert mocked_is_north_valid.called
+
+ def test_start_good(self, event_loop):
+ """ Unit tests - _start """
+
+ with patch.object(asyncio, 'get_event_loop', return_value=event_loop):
+ sp = SendingProcess()
+
+ sp._plugin = MagicMock()
+ sp._config['enable'] = True
+ sp._config_from_manager = {}
+
+ with patch.object(sp, '_is_stream_id_valid', return_value=True) as mocked_is_stream_id_valid:
+ with patch.object(sp, '_retrieve_configuration') as mocked_retrieve_configuration:
+ with patch.object(sp, '_plugin_load') as mocked_plugin_load:
+ with patch.object(sp._plugin, 'plugin_info') as mocked_plugin_info:
+ with patch.object(sp, '_is_north_valid', return_value=True) as mocked__is_north_valid:
+ with patch.object(sp, '_retrieve_configuration') as mocked_retrieve_configuration:
+ with patch.object(sp._plugin, 'plugin_init') as mocked_plugin_init:
+ result = sp._start(STREAM_ID)
+
+ assert result
+ mocked_is_stream_id_valid.called_with(STREAM_ID)
+ mocked__retrieve_configuration.called_with(STREAM_ID, True)
+ assert mocked_plugin_load.called
+ assert mocked_plugin_info.called
+ assert mocked_is_north_valid.called
+ assert mocked_retrieve_configuration.called
+ assert mocked_plugin_init.called
