diff --git a/force_bdss/bdss_application.py b/force_bdss/bdss_application.py index a822528477d75c8a36ca856b41a5c753d46106b2..4e5d49b188c33e50ee6e364d78fd95afc8b374ad 100644 --- a/force_bdss/bdss_application.py +++ b/force_bdss/bdss_application.py @@ -6,8 +6,9 @@ from stevedore.exception import NoMatches from envisage.api import Application from envisage.core_plugin import CorePlugin -from traits.api import Unicode, Bool +from traits.api import Unicode, Bool, Property +from force_bdss.ids import InternalPluginID from .factory_registry_plugin import FactoryRegistryPlugin from .core_evaluation_driver import CoreEvaluationDriver from .core_mco_driver import CoreMCODriver @@ -28,6 +29,9 @@ class BDSSApplication(Application): #: coordination of the MCO itself. See design notes for more details. evaluate = Bool() + #: Gives the currently opened workflow + workflow = Property() + def __init__(self, evaluate, workflow_filepath): self.evaluate = evaluate self.workflow_filepath = workflow_filepath @@ -53,6 +57,15 @@ class BDSSApplication(Application): super(BDSSApplication, self).__init__(plugins=plugins) + def _get_workflow(self): + if self.evaluate: + plugin = self.get_plugin( + InternalPluginID.CORE_EVALUATION_DRIVER_ID) + else: + plugin = self.get_plugin(InternalPluginID.CORE_MCO_DRIVER_ID) + + return plugin.workflow + def _import_extensions(plugins, ext): """Service routine extracted for testing. diff --git a/force_bdss/tests/test_bdss_application.py b/force_bdss/tests/test_bdss_application.py index ea3215d8b55816979b64947dba3826bb91664c53..b985316a62ff76e462601232f23baffac7bbe6ec 100644 --- a/force_bdss/tests/test_bdss_application.py +++ b/force_bdss/tests/test_bdss_application.py @@ -8,6 +8,8 @@ from force_bdss.bdss_application import ( _load_failure_callback, _import_extensions ) +from force_bdss.core.workflow import Workflow +from force_bdss.tests import fixtures try: import mock @@ -48,3 +50,18 @@ class TestBDSSApplication(unittest.TestCase): _import_extensions(plugins, ext) self.assertEqual(plugins[0], plugin) + + def test_workflow(self): + with testfixtures.LogCapture(): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + app = BDSSApplication(False, fixtures.get("test_empty.json")) + + self.assertIsInstance(app.workflow, Workflow) + + with testfixtures.LogCapture(): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + app = BDSSApplication(True, fixtures.get("test_empty.json")) + + self.assertIsInstance(app.workflow, Workflow)