Back to index

plone3  3.1.7
Public Member Functions
PluginRegistry.tests.test_exportimport.Test_importPluginRegistry Class Reference
Inheritance diagram for PluginRegistry.tests.test_exportimport.Test_importPluginRegistry:
Inheritance graph
[legend]
Collaboration diagram for PluginRegistry.tests.test_exportimport.Test_importPluginRegistry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty_default_purge
def test_empty_explicit_purge
def test_empty_skip_purge
def test_normal_no_plugins
def test_normal_with_plugins
def test_normal_with_plugins_skip_duplicates

Detailed Description

Definition at line 296 of file test_exportimport.py.


Member Function Documentation

Definition at line 298 of file test_exportimport.py.

00298 
00299         def test_empty_default_purge(self):
00300             from Products.PluginRegistry.exportimport \
00301                 import importPluginRegistry
00302 
00303             app, registry = self._initRegistry(
00304                                     plugin_type_info=_PLUGIN_TYPE_INFO,
00305                                     plugins={IFoo: ('foo_plugin_1',
00306                                                     'foo_plugin_2')},
00307                                    )
00308 
00309             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00310             self.assertEqual(len(registry.listPlugins(IFoo)), 2)
00311             self.assertEqual(len(registry.listPlugins(IBar)), 0)
00312 
00313             context = DummyImportContext(app)
00314             context._files['pluginregistry.xml'] = _EMPTY_PLUGINREGISTRY_EXPORT
00315 
00316             importPluginRegistry(context)
00317 
00318             self.assertEqual(len(registry.listPluginTypeInfo()), 0)
00319             self.assertRaises(KeyError, registry.listPlugins, IFoo)
00320             self.assertRaises(KeyError, registry.listPlugins, IBar)

Here is the call graph for this function:

Definition at line 321 of file test_exportimport.py.

00321 
00322         def test_empty_explicit_purge(self):
00323             from Products.PluginRegistry.exportimport \
00324                 import importPluginRegistry
00325 
00326             app, registry = self._initRegistry(
00327                                     plugin_type_info=_PLUGIN_TYPE_INFO,
00328                                     plugins={IFoo: ('foo_plugin_1',
00329                                                     'foo_plugin_2')},
00330                                    )
00331 
00332             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00333             self.assertEqual(len(registry.listPlugins(IFoo)), 2)
00334             self.assertEqual(len(registry.listPlugins(IBar)), 0)
00335 
00336             context = DummyImportContext(app, True)
00337             context._files['pluginregistry.xml'] = _EMPTY_PLUGINREGISTRY_EXPORT
00338 
00339             importPluginRegistry(context)
00340 
00341             self.assertEqual(len(registry.listPluginTypeInfo()), 0)
00342             self.assertRaises(KeyError, registry.listPlugins, IFoo)
00343             self.assertRaises(KeyError, registry.listPlugins, IBar)

Here is the call graph for this function:

Definition at line 344 of file test_exportimport.py.

00344 
00345         def test_empty_skip_purge(self):
00346             from Products.PluginRegistry.exportimport \
00347                 import importPluginRegistry
00348 
00349             app, registry = self._initRegistry(
00350                                     plugin_type_info=_PLUGIN_TYPE_INFO,
00351                                     plugins={IFoo: ('foo_plugin_1',
00352                                                     'foo_plugin_2')},
00353                                    )
00354 
00355             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00356             self.assertEqual(len(registry.listPlugins(IFoo)), 2)
00357             self.assertEqual(len(registry.listPlugins(IBar)), 0)
00358 
00359             context = DummyImportContext(app, False)
00360             context._files['pluginregistry.xml'] = _EMPTY_PLUGINREGISTRY_EXPORT
00361 
00362             importPluginRegistry(context)
00363 
00364             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00365             self.assertEqual(len(registry.listPlugins(IFoo)), 2)
00366             self.assertEqual(len(registry.listPlugins(IBar)), 0)

Here is the call graph for this function:

Definition at line 367 of file test_exportimport.py.

00367 
00368         def test_normal_no_plugins(self):
00369             from Products.PluginRegistry.exportimport \
00370                 import importPluginRegistry
00371 
00372             app, registry = self._initRegistry(plugins={IFoo: ('foo_plugin_1',
00373                                                                'foo_plugin_2')},
00374                                               )
00375 
00376             self.assertEqual(len(registry.listPluginTypeInfo()), 0)
00377             self.assertRaises(KeyError, registry.listPlugins, IFoo)
00378             self.assertRaises(KeyError, registry.listPlugins, IBar)
00379 
00380             context = DummyImportContext(app, False)
00381             context._files['pluginregistry.xml'
00382                           ] = _NO_PLUGINS_PLUGINREGISTRY_EXPORT
00383 
00384             importPluginRegistry(context)
00385 
00386             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00387 
00388             info = registry.listPluginTypeInfo()[0]
00389             self.assertEqual(info['id'], 'IFoo')
00390             self.assertEqual(info['title'], 'foo')
00391             self.assertEqual(info['description'], 'Some plugin interface')
00392 
00393             info = registry.listPluginTypeInfo()[1]
00394             self.assertEqual(info['id'], 'IBar')
00395             self.assertEqual(info['title'], 'bar')
00396             self.assertEqual(info['description'], 'Another plugin interface')
00397 
00398             self.assertEqual(len(registry.listPlugins(IFoo)), 0)
00399             self.assertEqual(len(registry.listPlugins(IBar)), 0)

Here is the call graph for this function:

Definition at line 400 of file test_exportimport.py.

00400 
00401         def test_normal_with_plugins(self):
00402             from Products.PluginRegistry.exportimport \
00403                 import importPluginRegistry
00404 
00405             app, registry = self._initRegistry(plugins={IFoo: ('foo_plugin_1',
00406                                                                'foo_plugin_2')},
00407                                               )
00408 
00409             self.assertEqual(len(registry.listPluginTypeInfo()), 0)
00410             self.assertRaises(KeyError, registry.listPlugins, IFoo)
00411             self.assertRaises(KeyError, registry.listPlugins, IBar)
00412 
00413             context = DummyImportContext(app, False)
00414             context._files['pluginregistry.xml'
00415                           ] = _NORMAL_PLUGINREGISTRY_EXPORT
00416 
00417             importPluginRegistry(context)
00418 
00419             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00420 
00421             info = registry.listPluginTypeInfo()[0]
00422             self.assertEqual(info['id'], 'IFoo')
00423             self.assertEqual(info['title'], 'foo')
00424             self.assertEqual(info['description'], 'Some plugin interface')
00425 
00426             info = registry.listPluginTypeInfo()[1]
00427             self.assertEqual(info['id'], 'IBar')
00428             self.assertEqual(info['title'], 'bar')
00429             self.assertEqual(info['description'], 'Another plugin interface')
00430 
00431             self.assertEqual(len(registry.listPlugins(IFoo)), 2)
00432             plugins = registry.listPlugins(IFoo)
00433             self.assertEqual(plugins[0][0], 'foo_plugin_1')
00434             self.assertEqual(plugins[0][1], app._getOb('foo_plugin_1'))
00435             self.assertEqual(plugins[1][0], 'foo_plugin_2')
00436             self.assertEqual(plugins[1][1], app._getOb('foo_plugin_2'))
00437 
00438             self.assertEqual(len(registry.listPlugins(IBar)), 0)

Here is the call graph for this function:

Definition at line 439 of file test_exportimport.py.

00439 
00440         def test_normal_with_plugins_skip_duplicates(self):
00441             # See http://www.zope.org/Collectors/PAS/52
00442             from Products.PluginRegistry.exportimport \
00443                 import importPluginRegistry
00444 
00445             app, registry = self._initRegistry()
00446 
00447             self.assertEqual(len(registry.listPluginTypeInfo()), 0)
00448             self.assertRaises(KeyError, registry.listPlugins, IFoo)
00449             self.assertRaises(KeyError, registry.listPlugins, IBar)
00450 
00451             context = DummyImportContext(app, False)
00452             context._files['pluginregistry.xml'
00453                           ] = _NORMAL_PLUGINREGISTRY_EXPORT
00454 
00455             importPluginRegistry(context)
00456             importPluginRegistry(context) # twice should not duplicate
00457 
00458             self.assertEqual(len(registry.listPluginTypeInfo()), 2)
00459 
    class AttrItemTraverser:

Here is the call graph for this function:


The documentation for this class was generated from the following file: