Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
PluggableAuthService.tests.test_exportimport.Test_exportPAS Class Reference
Inheritance diagram for PluggableAuthService.tests.test_exportimport.Test_exportPAS:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.tests.test_exportimport.Test_exportPAS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty
def test_with_contents

Private Member Functions

def _setUpAdapters

Detailed Description

Definition at line 62 of file test_exportimport.py.


Member Function Documentation

Definition at line 64 of file test_exportimport.py.

00064 
00065         def _setUpAdapters(self):
00066             from zope.app.testing import ztapi
00067 
00068             try:
00069                 from OFS.interfaces import IObjectManager
00070                 from OFS.interfaces import ISimpleItem
00071                 from OFS.interfaces import IPropertyManager
00072             except ImportError: # BBB
00073                 from Products.Five.interfaces import IObjectManager
00074                 from Products.Five.interfaces import ISimpleItem
00075                 from Products.Five.interfaces import IPropertyManager
00076 
00077             from Products.GenericSetup.interfaces import IContentFactoryName
00078             from Products.GenericSetup.interfaces import ICSVAware
00079             from Products.GenericSetup.interfaces import IDAVAware
00080             from Products.GenericSetup.interfaces import IFilesystemExporter
00081             from Products.GenericSetup.interfaces import IINIAware
00082             from Products.GenericSetup.content import \
00083                 FolderishExporterImporter
00084             from Products.GenericSetup.content import \
00085                 SimpleINIAware
00086             from Products.GenericSetup.content import \
00087                 CSVAwareFileAdapter
00088             from Products.GenericSetup.content import \
00089                 INIAwareFileAdapter
00090             from Products.GenericSetup.content import \
00091                 DAVAwareFileAdapter
00092 
00093             from Products.PluginRegistry.interfaces import IPluginRegistry
00094             from Products.PluginRegistry.exportimport \
00095                 import PluginRegistryFileExportImportAdapter
00096 
00097             from Products.PluggableAuthService.exportimport \
00098                 import PAS_CF_Namer
00099 
00100             ztapi.provideAdapter(IObjectManager,
00101                                  IFilesystemExporter,
00102                                  FolderishExporterImporter,
00103                                 )
00104 
00105             ztapi.provideAdapter(IPropertyManager,
00106                                  IINIAware,
00107                                  SimpleINIAware,
00108                                 )
00109 
00110             ztapi.provideAdapter(ICSVAware,
00111                                  IFilesystemExporter,
00112                                  CSVAwareFileAdapter,
00113                                 )
00114 
00115             ztapi.provideAdapter(IINIAware,
00116                                  IFilesystemExporter,
00117                                  INIAwareFileAdapter,
00118                                 )
00119 
00120             ztapi.provideAdapter(IDAVAware,
00121                                  IFilesystemExporter,
00122                                  DAVAwareFileAdapter,
00123                                 )
00124 
00125             ztapi.provideAdapter(IPluginRegistry,
00126                                  IFilesystemExporter,
00127                                  PluginRegistryFileExportImportAdapter,
00128                                 )
00129 
00130             ztapi.provideAdapter(IPluginRegistry,
00131                                  IContentFactoryName,
00132                                  PAS_CF_Namer,
00133                                 )

Here is the caller graph for this function:

Definition at line 134 of file test_exportimport.py.

00134 
00135         def test_empty(self):
00136             from Products.GenericSetup.utils import _getDottedName
00137             from Products.GenericSetup.tests.common import DummyExportContext
00138             from Products.PluginRegistry.PluginRegistry import PluginRegistry
00139             from Products.PluggableAuthService.exportimport import exportPAS
00140 
00141             _setUpDefaultTraversable()
00142 
00143             self._setUpAdapters()
00144             app, pas = self._initPAS()
00145             context = DummyExportContext(pas)
00146             exportPAS(context)
00147 
00148             self.assertEqual(len(context._wrote), 3)
00149             filename, text, content_type = context._wrote[0]
00150             self.assertEqual(filename, 'PAS/.objects')
00151             self.assertEqual(content_type, 'text/comma-separated-values')
00152             self.assertEqual(text.splitlines(),
00153                              _EMPTY_PAS_OBJECTS.splitlines())
00154 
00155             filename, text, content_type = context._wrote[1]
00156             self.assertEqual(filename, 'PAS/.properties')
00157             self.assertEqual(content_type, 'text/plain')
00158             lines = filter(None, [x.strip() for x in text.splitlines()])
00159             self.assertEqual(len(lines), 2)
00160             self.assertEqual(lines[0], '[DEFAULT]')
00161             self.assertEqual(lines[1], 'title =')
00162 
00163             filename, text, content_type = context._wrote[2]
00164             self.assertEqual(filename, 'PAS/pluginregistry.xml')
00165             self.assertEqual(content_type, 'text/xml')

Here is the call graph for this function:

Definition at line 166 of file test_exportimport.py.

00166 
00167         def test_with_contents(self):
00168             from Products.GenericSetup.tests.common import DummyExportContext
00169             from Products.GenericSetup.tests.faux_objects \
00170                 import TestCSVAware
00171             from Products.GenericSetup.utils import _getDottedName
00172             from Products.PluginRegistry.PluginRegistry import PluginRegistry
00173             from Products.PluggableAuthService.exportimport import exportPAS
00174 
00175             _setUpDefaultTraversable()
00176 
00177             self._setUpAdapters()
00178             app, pas = self._initPAS()
00179             csv_aware = TestCSVAware()
00180             csv_aware._setId('csv_plugin')
00181             pas._setObject('csv_plugin', csv_aware)
00182             context = DummyExportContext(pas)
00183             exportPAS(context)
00184 
00185             self.assertEqual(len(context._wrote), 4)
00186             filename, text, content_type = context._wrote[0]
00187             self.assertEqual(filename, 'PAS/.objects')
00188             self.assertEqual(content_type, 'text/comma-separated-values')
00189 
00190             objects = [x for x in reader(StringIO(text))]
00191             self.assertEqual(len(objects), 2)
00192 
00193             object_id, type_name = objects[0]
00194             self.assertEqual(object_id, 'plugins')
00195             self.assertEqual(type_name, 'plugins') # adapter-driven
00196 
00197             object_id, type_name = objects[1]
00198             self.assertEqual(object_id, 'csv_plugin')
00199             self.assertEqual(type_name, _getDottedName(csv_aware.__class__))
00200 
00201             filename, text, content_type = context._wrote[1]
00202             self.assertEqual(filename, 'PAS/.properties')
00203             self.assertEqual(content_type, 'text/plain')
00204             lines = filter(None, [x.strip() for x in text.splitlines()])
00205             self.assertEqual(len(lines), 2)
00206             self.assertEqual(lines[0], '[DEFAULT]')
00207             self.assertEqual(lines[1], 'title =')
00208 
00209             filename, text, content_type = context._wrote[2]
00210             self.assertEqual(filename, 'PAS/pluginregistry.xml')
00211             self.assertEqual(content_type, 'text/xml')
00212 
00213             filename, text, content_type = context._wrote[3]
00214             self.assertEqual(filename, 'PAS/csv_plugin.csv')
00215             self.assertEqual(content_type, 'text/comma-separated-values')
00216 
    class Test_importPAS(_TestBase):

Here is the call graph for this function:


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