Skip to content
Snippets Groups Projects
Commit 5bbf45b9 authored by Stefano Borini's avatar Stefano Borini
Browse files

coverage

parent 28bc3313
No related branches found
No related tags found
1 merge request!138More robust logging for BDSS
......@@ -66,12 +66,11 @@ class CoreMCODriver(BaseCoreDriver):
try:
optimizer = mco_factory.create_optimizer()
except Exception:
factory_id = mco_factory.id,
plugin_id = mco_factory.plugin.id
log.exception("Unable to instantiate optimizer for mco '{}' in "
"plugin '{}'. An exception was raised. "
"This might indicate a programming error in the "
"plugin.".format(factory_id, plugin_id))
"plugin.".format(mco_factory.id,
mco_factory.plugin.id))
raise
return optimizer
......
......@@ -135,3 +135,44 @@ class TestCoreMCODriver(unittest.TestCase):
"'force.bdss.enthought.plugin.test.v0"
".factory.probe_notification_listener' in plugin "
"'force.bdss.enthought.plugin.test.v0'."))
def test_listener_creation_error(self):
driver = CoreMCODriver(
application=self.mock_application,
)
registry = self.factory_registry_plugin
nl_factory = registry.notification_listener_factories[0]
nl_factory.raises_on_create_listener = True
with LogCapture() as capture:
with self.assertRaises(Exception):
driver.listeners
capture.check(('force_bdss.core_mco_driver',
'ERROR',
'Failed to create listener with id '
"'force.bdss.enthought.plugin.test.v0"
".factory.probe_notification_listener' "
"in plugin 'force.bdss.enthought.plugin"
".test.v0'. This may indicate a "
'programming error in the plugin.'),)
def test_create_optimizer_error(self):
driver = CoreMCODriver(
application=self.mock_application,
)
registry = self.factory_registry_plugin
mco_factory = registry.mco_factories[0]
mco_factory.raises_on_create_optimizer = True
with LogCapture() as capture:
with self.assertRaises(Exception):
driver.mco
capture.check(('force_bdss.core_mco_driver',
'ERROR',
'Unable to instantiate optimizer for mco '
"'force.bdss.enthought.plugin.test.v0"
".factory.probe_mco' in plugin "
"'force.bdss.enthought.plugin.test.v0'. "
"An exception was raised. This might "
'indicate a programming error in the plugin.'),)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment