Example #1
0
 def test_plugin_wrapper_exceptions(self):
     """Verify the plugin_wrapper function properly returns Exception info"""
     plugin_queue = multiprocessing.Queue()
     plugin_exception_queue = multiprocessing.Queue()
     plugin_data = np.array(self.random_data())
     model.plugin_wrapper(exception_queue=plugin_exception_queue,
                          plugin_cls=ExceptionPlugin,
                          plugin_data=plugin_data,
                          plugin_queue=plugin_queue)
     exc_type, exc = plugin_exception_queue.get(block=True)
     self.assertTrue(isinstance(exc, Exception))
Example #2
0
 def test_plugin_wrapper(self):
     """Verify the plugin_wrapper function properly configures and runs a plugin"""
     plugin_queue = multiprocessing.Queue()
     plugin_exception_queue = multiprocessing.Queue()
     plugin_data = np.array(self.random_data())
     plugin_cfg = {'a': 'c'}
     kwargs = {'name': 'Mock Plugin', 'description': 'Mock plugin used to test plugin_wrapper'}
     model.plugin_wrapper(plugin_exception_queue, MockPlugin, plugin_data, plugin_queue, plugin_cfg,
                          **kwargs)
     returned_data = plugin_queue.get()
     self.assertTrue(isinstance(returned_data, dict))
     self.assertDictEqual(returned_data['config'], plugin_cfg)
     self.assertDictEqual(returned_data['kwargs'], kwargs)
     self.assertTrue(np.array_equal(returned_data['data'], plugin_data))