Back to index

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

List of all members.

Public Member Functions

def test_listExportableItems
def test__getExportInfo_empty
def test_export_empty
def test__getExportInfo_with_groups
def test_export_with_groups
def test_import_empty
def test_import_without_purge_leaves_existing_users
def test_import_with_purge_wipes_existing_users

Private Member Functions

def _getTargetClass
def _makePlugin

Detailed Description

Definition at line 190 of file test_exportimport.py.


Member Function Documentation

Definition at line 192 of file test_exportimport.py.

00192 
00193         def _getTargetClass(self):
00194             from Products.PluggableAuthService.plugins.exportimport \
00195                 import ZODBGroupManagerExportImport
00196             return ZODBGroupManagerExportImport

Definition at line 197 of file test_exportimport.py.

00197 
00198         def _makePlugin(self, id, *args, **kw):
00199             from Products.PluggableAuthService.plugins.ZODBGroupManager \
00200                 import ZODBGroupManager
00201             return ZODBGroupManager(id, *args, **kw)

Definition at line 209 of file test_exportimport.py.

00209 
00210         def test__getExportInfo_empty(self):
00211             plugin = self._makePlugin('empty').__of__(self.root)
00212             adapter = self._makeOne(plugin)
00213 
00214             info = adapter._getExportInfo()
00215             self.assertEqual(info['title'], None)
00216             self.assertEqual(len(info['groups']), 0)

Definition at line 230 of file test_exportimport.py.

00230 
00231         def test__getExportInfo_with_groups(self):
00232 
00233             plugin = self._makePlugin('with_groups').__of__(self.root)
00234             plugin.title = 'Plugin Title'
00235 
00236             for g in _ZODB_GROUP_INFO:
00237                 plugin.addGroup(g['group_id'], g['title'], g['description'])
00238                 for principal in g['principals']:
00239                     plugin.addPrincipalToGroup(principal, g['group_id'])
00240 
00241             adapter = self._makeOne(plugin)
00242 
00243             info = adapter._getExportInfo()
00244             self.assertEqual(info['title'], 'Plugin Title')
00245             self.assertEqual(len(info['groups']), len(_ZODB_GROUP_INFO))
00246 
00247             for x, y in zip(info['groups'], _ZODB_GROUP_INFO):
00248                 self.assertEqual(x, y)

Definition at line 217 of file test_exportimport.py.

00217 
00218         def test_export_empty(self):
00219             plugin = self._makePlugin('empty').__of__(self.root)
00220             adapter = self._makeOne(plugin)
00221 
00222             context = DummyExportContext(plugin)
00223             adapter.export(context, 'plugins', False)
00224 
00225             self.assertEqual( len( context._wrote ), 1 )
00226             filename, text, content_type = context._wrote[ 0 ]
00227             self.assertEqual( filename, 'plugins/empty.xml' )
00228             self._compareDOM( text, _EMPTY_ZODB_GROUPS )
00229             self.assertEqual( content_type, 'text/xml' )

Definition at line 249 of file test_exportimport.py.

00249 
00250         def test_export_with_groups(self):
00251 
00252             plugin = self._makePlugin('with_groups').__of__(self.root)
00253             plugin.title = 'Plugin Title'
00254 
00255             for g in _ZODB_GROUP_INFO:
00256                 plugin.addGroup(g['group_id'], g['title'], g['description'])
00257                 for principal in g['principals']:
00258                     plugin.addPrincipalToGroup(principal, g['group_id'])
00259 
00260             adapter = self._makeOne(plugin)
00261             context = DummyExportContext(plugin)
00262             adapter.export(context, 'plugins', False)
00263 
00264             self.assertEqual( len(context._wrote), 1)
00265             filename, text, content_type = context._wrote[ 0 ]
00266             self.assertEqual(filename, 'plugins/with_groups.xml')
00267             self._compareDOM(text, _FILLED_ZODB_GROUPS)
00268             self.assertEqual(content_type, 'text/xml')

Definition at line 269 of file test_exportimport.py.

00269 
00270         def test_import_empty(self):
00271             plugin = self._makePlugin('empty').__of__(self.root)
00272             adapter = self._makeOne(plugin)
00273 
00274             context = DummyImportContext(plugin)
00275             context._files['plugins/empty.xml'] = _FILLED_ZODB_GROUPS
00276             self.assertEqual(plugin.title, None)
00277 
00278             adapter.import_(context, 'plugins', False)
00279 
00280             found = plugin.listGroupInfo()
00281             self.assertEqual(len(found), len(_ZODB_GROUP_INFO))
00282             self.assertEqual(plugin.title, 'Plugin Title')
00283 
00284             for finfo, ginfo in zip(found, _ZODB_GROUP_INFO):
00285                 self.assertEqual(finfo['id'], ginfo['group_id'])
00286                 self.assertEqual(finfo['title'], ginfo['title'])
00287                 self.assertEqual(finfo['description'], ginfo['description'])
00288                 for principal_id in ginfo['principals']:
00289                     groups = plugin._principal_groups[principal_id]
00290                     self.failUnless(ginfo['group_id'] in groups)

Definition at line 311 of file test_exportimport.py.

00311 
00312         def test_import_with_purge_wipes_existing_users(self):
00313 
00314             plugin = self._makePlugin('with_groups').__of__(self.root)
00315             plugin.title = 'Plugin Title'
00316 
00317             for g in _ZODB_GROUP_INFO:
00318                 plugin.addGroup(g['group_id'], g['title'], g['description'])
00319                 for principal in g['principals']:
00320                     plugin.addPrincipalToGroup(principal, g['group_id'])
00321 
00322             adapter = self._makeOne(plugin)
00323 
00324             context = DummyImportContext(plugin, purge=True)
00325             context._files['plugins/with_groups.xml'] = _EMPTY_ZODB_GROUPS
00326 
00327             self.assertEqual(len(plugin._groups), len(_ZODB_GROUP_INFO))
00328             adapter.import_(context, 'plugins', False)
00329             self.assertEqual(len(plugin._groups), 0)
00330             self.assertEqual(plugin.title, None)
00331 
    class ZODBRoleManagerExportImportTests(_TestBase):

Definition at line 291 of file test_exportimport.py.

00291 
00292         def test_import_without_purge_leaves_existing_users(self):
00293 
00294             plugin = self._makePlugin('with_groups').__of__(self.root)
00295             plugin.title = 'Plugin Title'
00296 
00297             for g in _ZODB_GROUP_INFO:
00298                 plugin.addGroup(g['group_id'], g['title'], g['description'])
00299                 for principal in g['principals']:
00300                     plugin.addPrincipalToGroup(principal, g['group_id'])
00301 
00302             adapter = self._makeOne(plugin)
00303 
00304             context = DummyImportContext(plugin, purge=False)
00305             context._files['plugins/with_groups.xml'] = _EMPTY_ZODB_GROUPS
00306 
00307             self.assertEqual(len(plugin._groups), len(_ZODB_GROUP_INFO))
00308             adapter.import_(context, 'plugins', False)
00309             self.assertEqual(len(plugin._groups), len(_ZODB_GROUP_INFO))
00310             self.assertEqual(plugin.title, None)

Definition at line 202 of file test_exportimport.py.

00202 
00203         def test_listExportableItems(self):
00204             plugin = self._makePlugin('lEI').__of__(self.root)
00205             adapter = self._makeOne(plugin)
00206             self.assertEqual(len(adapter.listExportableItems()), 0)
00207             plugin.addGroup('group_id', 'title', 'description')
00208             self.assertEqual(len(adapter.listExportableItems()), 0)


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