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

Final fixes

parent 534b838c
No related branches found
No related tags found
1 merge request!71Rename bundle to factory
Showing
with 47 additions and 46 deletions
import unittest
from force_bdss.core_plugins.dummy.tests.data_source_factory_test_mixin import \
DataSourceFactoryTestMixin
from force_bdss.core_plugins.dummy.tests.data_source_factory_test_mixin \
import DataSourceFactoryTestMixin
from force_bdss.core_plugins.dummy.csv_extractor.csv_extractor_factory import \
CSVExtractorFactory
from force_bdss.core_plugins.dummy.csv_extractor.csv_extractor_data_source \
......
......@@ -20,18 +20,18 @@ from force_bdss.core_plugins.dummy.dummy_dakota.dakota_optimizer import \
class TestDakotaOptimizer(unittest.TestCase):
def setUp(self):
self.bundle = mock.Mock(spec=BaseMCOFactory)
self.bundle.plugin = mock.Mock()
self.bundle.plugin.application = mock.Mock()
self.bundle.plugin.application.workflow_filepath = "whatever"
self.factory = mock.Mock(spec=BaseMCOFactory)
self.factory.plugin = mock.Mock()
self.factory.plugin.application = mock.Mock()
self.factory.plugin.application.workflow_filepath = "whatever"
def test_initialization(self):
opt = DummyDakotaOptimizer(self.bundle)
self.assertEqual(opt.factory, self.bundle)
opt = DummyDakotaOptimizer(self.factory)
self.assertEqual(opt.factory, self.factory)
def test_run(self):
opt = DummyDakotaOptimizer(self.bundle)
model = DummyDakotaModel(self.bundle)
opt = DummyDakotaOptimizer(self.factory)
model = DummyDakotaModel(self.factory)
model.parameters = [
RangedMCOParameter(
mock.Mock(spec=RangedMCOParameterFactory),
......
......@@ -6,11 +6,12 @@ from force_bdss.core_plugins.dummy.dummy_data_source\
.dummy_data_source_factory import DummyDataSourceFactory
from force_bdss.core_plugins.dummy.dummy_data_source.dummy_data_source_model\
import DummyDataSourceModel
from force_bdss.core_plugins.dummy.tests.data_source_factory_test_mixin import \
DataSourceFactoryTestMixin
from force_bdss.core_plugins.dummy.tests.data_source_factory_test_mixin \
import DataSourceFactoryTestMixin
class TestDummyDataSourceBundle(DataSourceFactoryTestMixin, unittest.TestCase):
class TestDummyDataSourceFactory(
DataSourceFactoryTestMixin, unittest.TestCase):
@property
def factory_class(self):
return DummyDataSourceFactory
......
......@@ -15,15 +15,15 @@ from force_bdss.core_plugins.dummy.dummy_kpi_calculator \
class TestDummyKPICalculator(unittest.TestCase):
def test_run(self):
bundle = mock.Mock(spec=DummyKPICalculatorFactory)
kpic = DummyKPICalculator(bundle)
model = DummyKPICalculatorModel(bundle)
factory = mock.Mock(spec=DummyKPICalculatorFactory)
kpic = DummyKPICalculator(factory)
model = DummyKPICalculatorModel(factory)
input_ = []
output = kpic.run(model, [])
self.assertEqual(input_, output)
def test_slots(self):
bundle = mock.Mock(spec=DummyKPICalculatorFactory)
kpic = DummyKPICalculator(bundle)
model = DummyKPICalculatorModel(bundle)
factory = mock.Mock(spec=DummyKPICalculatorFactory)
kpic = DummyKPICalculator(factory)
model = DummyKPICalculatorModel(factory)
self.assertEqual(kpic.slots(model), ((), ()))
......@@ -14,7 +14,7 @@ from force_bdss.core_plugins.dummy.tests.kpi_calculator_factory_test_mixin \
KPICalculatorFactoryTestMixin
class TestDummyKPICalculatorBundle(
class TestDummyKPICalculatorFactory(
KPICalculatorFactoryTestMixin, unittest.TestCase):
@property
......
......@@ -11,13 +11,13 @@ from .dummy_kpi_calculator.dummy_kpi_calculator_factory import (
class DummyPlugin(BaseExtensionPlugin):
id = plugin_id("enthought", "DummyPlugin")
def _data_source_bundles_default(self):
def _data_source_factories_default(self):
return [DummyDataSourceFactory(self),
CSVExtractorFactory(self)]
def _mco_bundles_default(self):
def _mco_factories_default(self):
return [DummyDakotaFactory(self)]
def _kpi_calculator_bundles_default(self):
def _kpi_calculator_factories_default(self):
return [DummyKPICalculatorFactory(self),
KPIAdderFactory(self)]
......@@ -11,7 +11,7 @@ from force_bdss.core_plugins.dummy.tests.kpi_calculator_factory_test_mixin \
KPICalculatorFactoryTestMixin
class TestDummyKPICalculatorBundle(
class TestDummyKPICalculatorFactory(
KPICalculatorFactoryTestMixin, unittest.TestCase):
@property
......
......@@ -7,19 +7,19 @@ from .i_data_source_factory import IDataSourceFactory
@provides(IDataSourceFactory)
class BaseDataSourceFactory(ABCHasStrictTraits):
"""Base class for DataSource bundles. Reimplement this class to
"""Base class for DataSource factories. Reimplement this class to
create your own DataSource.
"""
# NOTE: changes to this class must be ported also to the IDataSourceBundle
# NOTE: changes to this class must be ported also to the IDataSourceFactory
#: Unique identifier that identifies the bundle uniquely in the
#: universe of bundles. Create one with the function bundle_id()
#: Unique identifier that identifies the factory uniquely in the
#: universe of factories. Create one with the function factory_id()
id = String()
#: A human readable name of the bundle. Spaces allowed
#: A human readable name of the factory. Spaces allowed
name = String()
#: Reference to the plugin that carries this bundle
#: Reference to the plugin that carries this factory
plugin = Instance(Plugin)
def __init__(self, plugin, *args, **kwargs):
......@@ -29,7 +29,7 @@ class BaseDataSourceFactory(ABCHasStrictTraits):
@abc.abstractmethod
def create_data_source(self):
"""Factory method.
Must return the bundle-specific BaseDataSource instance.
Must return the factory-specific BaseDataSource instance.
Returns
-------
......
......@@ -5,14 +5,14 @@ from .i_data_source_factory import IDataSourceFactory
class BaseDataSourceModel(ABCHasStrictTraits):
"""Base class for the bundle specific DataSource models.
"""Base class for the factory specific DataSource models.
This model will also provide, through traits/traitsui magic the View
that will appear in the workflow manager UI.
In your bundle definition, your bundle-specific model must reimplement
In your factory definition, your factory-specific model must reimplement
this class.
"""
#: A reference to the creating bundle, so that we can
#: A reference to the creating factory, so that we can
#: retrieve it as the originating factory.
factory = Instance(IDataSourceFactory, visible=False, transient=True)
......
......@@ -9,7 +9,7 @@ from force_bdss.data_sources.base_data_source_factory import \
BaseDataSourceFactory
class DummyDataSourceBundle(BaseDataSourceFactory):
class DummyDataSourceFactory(BaseDataSourceFactory):
id = "foo"
name = "bar"
......@@ -21,8 +21,8 @@ class DummyDataSourceBundle(BaseDataSourceFactory):
pass
class TestBaseDataSourceBundle(unittest.TestCase):
class TestBaseDataSourceFactory(unittest.TestCase):
def test_initialization(self):
bundle = DummyDataSourceBundle(mock.Mock(spec=Plugin))
self.assertEqual(bundle.id, 'foo')
self.assertEqual(bundle.name, 'bar')
factory = DummyDataSourceFactory(mock.Mock(spec=Plugin))
self.assertEqual(factory.id, 'foo')
self.assertEqual(factory.name, 'bar')
......@@ -2,7 +2,7 @@ import six
class ExtensionPointID:
"""The envisage extension points ids for the bundles ExtensionPoints.
"""The envisage extension points ids for the factorys ExtensionPoints.
These are populated by the envisage plugins.
The plugin developer generally does not have to handle these identifiers,
......@@ -27,7 +27,7 @@ def factory_id(producer, identifier):
Returns
-------
str: an identifier to be used in the bundle.
str: an identifier to be used in the factory.
"""
return _string_id(producer, "factory", identifier)
......@@ -55,16 +55,16 @@ def _string_id(*args):
Parameters
----------
entity_namespace: str
A namespace for the entity we want to address (e.g. "bundle")
A namespace for the entity we want to address (e.g. "factory")
producer: str
the company or research institute unique identifier (e.g. "enthought")
identifier: str
A unique identifier for the bundle. The producer has authority and
A unique identifier for the factory. The producer has authority and
control over the uniqueness of this identifier.
Returns
-------
str: an identifier to be used in the bundle.
str: an identifier to be used in the factory.
"""
def is_valid(entry):
return (
......
......@@ -33,7 +33,7 @@ class TestWorkflowWriter(unittest.TestCase):
mock_mco_factory.create_model = mock.Mock(
return_value=mock_mco_model
)
self.mock_registry.mco_bundle_by_id = mock.Mock(
self.mock_registry.mco_factory_by_id = mock.Mock(
return_value=mock_mco_factory)
def test_write(self):
......
......@@ -10,7 +10,7 @@ class BaseKPICalculator(ABCHasStrictTraits):
Inherit this class for your KPI calculator.
"""
#: A reference to the bundle
#: A reference to the factory
factory = Instance(IKPICalculatorFactory)
def __init__(self, factory, *args, **kwargs):
......
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