Example #1
0
class TestFactoryRegistryWithContent(unittest.TestCase):
    def setUp(self):
        self.plugin = DummyExtensionPlugin()
        self.plugin.start()
        self.registry = FactoryRegistry(
            mco_factories=[DummyMCOFactory(plugin=self.plugin)],
            data_source_factories=[DummyDataSourceFactory(plugin=self.plugin)],
            notification_listener_factories=[
                DummyNotificationListenerFactory(plugin=self.plugin),
            ],
        )

    def tearDown(self):
        self.plugin.stop()

    def test_initialization(self):
        self.assertEqual(len(self.registry.mco_factories), 1)
        self.assertEqual(len(self.registry.data_source_factories), 1)
        self.assertEqual(len(self.registry.notification_listener_factories), 1)

    def test_lookup(self):
        mco_id = factory_id(self.plugin.id, "dummy_mco")
        parameter_id = mco_parameter_id(mco_id, "dummy_mco_parameter")
        self.assertEqual(self.registry.mco_factory_by_id(mco_id).id, mco_id)
        self.registry.mco_parameter_factory_by_id(mco_id, parameter_id)

        id = factory_id(self.plugin.id, "dummy_data_source")
        self.assertEqual(self.registry.data_source_factory_by_id(id).id, id)

        id = factory_id(self.plugin.id, "dummy_notification_listener")
        self.assertEqual(
            self.registry.notification_listener_factory_by_id(id).id,
            id)

        with self.assertRaises(KeyError):
            self.registry.mco_factory_by_id(
                factory_id(self.plugin.id, "foo"))

        with self.assertRaises(KeyError):
            self.registry.mco_parameter_factory_by_id(
                mco_id,
                mco_parameter_id(mco_id, "foo")
            )

        with self.assertRaises(KeyError):
            self.registry.data_source_factory_by_id(
                factory_id(self.plugin.id, "foo")
            )

        with self.assertRaises(KeyError):
            self.registry.data_source_factory_by_id(
                factory_id(self.plugin.id, "foo")
            )

        with self.assertRaises(KeyError):
            self.registry.notification_listener_factory_by_id(
                factory_id(self.plugin.id, "foo")
            )
Example #2
0
 def setUp(self):
     self.plugin = DummyExtensionPlugin()
     self.plugin.start()
     self.registry = FactoryRegistry(
         mco_factories=[DummyMCOFactory(plugin=self.plugin)],
         data_source_factories=[DummyDataSourceFactory(plugin=self.plugin)],
         notification_listener_factories=[
             DummyNotificationListenerFactory(plugin=self.plugin),
         ],
     )
Example #3
0
 def setUp(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         self.registry = FactoryRegistryPlugin()
         self.plugin = DummyExtensionPlugin()
         self.app = Application([self.registry, self.plugin])
         self.app.start()
         self.app.stop()
Example #4
0
 def _plugin_default(self):
     return DummyExtensionPlugin()
Example #5
0
 def setUp(self):
     self.plugin = DummyExtensionPlugin()
     self.workflow = Workflow()
Example #6
0
 def setUp(self):
     self.plugins = [DummyExtensionPlugin(), DummyUIPlugin()]
     super(TestUISelectModal, self).setUp()
Example #7
0
    def setUp(self):

        self.plugin = DummyExtensionPlugin()
        self.factory = DummyFactory(self.plugin)
        self.model = ProbeDataSourceModel(self.factory)