Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
PluggableAuthService.plugins.tests.test_exportimport.ZODBRoleManagerExportImportTests Class Reference
Inheritance diagram for PluggableAuthService.plugins.tests.test_exportimport.ZODBRoleManagerExportImportTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.plugins.tests.test_exportimport.ZODBRoleManagerExportImportTests:
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_roles
def test_export_with_roles
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 331 of file test_exportimport.py.


Member Function Documentation

Definition at line 333 of file test_exportimport.py.

00333 
00334         def _getTargetClass(self):
00335             from Products.PluggableAuthService.plugins.exportimport \
00336                 import ZODBRoleManagerExportImport
00337             return ZODBRoleManagerExportImport

Definition at line 338 of file test_exportimport.py.

00338 
00339         def _makePlugin(self, id, *args, **kw):
00340             from Products.PluggableAuthService.plugins.ZODBRoleManager \
00341                 import ZODBRoleManager
00342             return ZODBRoleManager(id, *args, **kw)

Definition at line 351 of file test_exportimport.py.

00351 
00352         def test__getExportInfo_empty(self):
00353             plugin = self._makePlugin('empty').__of__(self.root)
00354             adapter = self._makeOne(plugin)
00355 
00356             info = adapter._getExportInfo()
00357             self.assertEqual(info['title'], None)
00358             self.assertEqual(len(info['roles']), 0)

Definition at line 372 of file test_exportimport.py.

00372 
00373         def test__getExportInfo_with_roles(self):
00374 
00375             plugin = self._makePlugin('with_roles').__of__(self.root)
00376             plugin.title = 'Plugin Title'
00377 
00378             for r in _ZODB_ROLE_INFO:
00379                 plugin.addRole(r['role_id'], r['title'], r['description'])
00380                 for principal in r['principals']:
00381                     plugin.assignRoleToPrincipal(r['role_id'], principal)
00382 
00383             adapter = self._makeOne(plugin)
00384 
00385             info = adapter._getExportInfo()
00386             self.assertEqual(info['title'], 'Plugin Title')
00387             self.assertEqual(len(info['roles']), len(_ZODB_ROLE_INFO))
00388 
00389             for x, y in zip(info['roles'], _ZODB_ROLE_INFO):
00390                 self.assertEqual(x, y)

Definition at line 359 of file test_exportimport.py.

00359 
00360         def test_export_empty(self):
00361             plugin = self._makePlugin('empty').__of__(self.root)
00362             adapter = self._makeOne(plugin)
00363 
00364             context = DummyExportContext(plugin)
00365             adapter.export(context, 'plugins', False)
00366 
00367             self.assertEqual( len( context._wrote ), 1 )
00368             filename, text, content_type = context._wrote[ 0 ]
00369             self.assertEqual( filename, 'plugins/empty.xml' )
00370             self._compareDOM( text, _EMPTY_ZODB_ROLES )
00371             self.assertEqual( content_type, 'text/xml' )

Definition at line 391 of file test_exportimport.py.

00391 
00392         def test_export_with_roles(self):
00393 
00394             plugin = self._makePlugin('with_roles').__of__(self.root)
00395             plugin.title = 'Plugin Title'
00396 
00397             for r in _ZODB_ROLE_INFO:
00398                 plugin.addRole(r['role_id'], r['title'], r['description'])
00399                 for principal in r['principals']:
00400                     plugin.assignRoleToPrincipal(r['role_id'], principal)
00401 
00402             adapter = self._makeOne(plugin)
00403             context = DummyExportContext(plugin)
00404             adapter.export(context, 'plugins', False)
00405 
00406             self.assertEqual( len(context._wrote), 1)
00407             filename, text, content_type = context._wrote[ 0 ]
00408             self.assertEqual(filename, 'plugins/with_roles.xml')
00409             self._compareDOM(text, _FILLED_ZODB_ROLES)
00410             self.assertEqual(content_type, 'text/xml')

Definition at line 411 of file test_exportimport.py.

00411 
00412         def test_import_empty(self):
00413             plugin = self._makePlugin('empty').__of__(self.root)
00414             adapter = self._makeOne(plugin)
00415 
00416             context = DummyImportContext(plugin)
00417             context._files['plugins/empty.xml'] = _FILLED_ZODB_ROLES
00418             self.assertEqual(plugin.title, None)
00419 
00420             adapter.import_(context, 'plugins', False)
00421 
00422             found = plugin.listRoleInfo()
00423             self.assertEqual(len(found), len(_ZODB_ROLE_INFO))
00424             self.assertEqual(plugin.title, 'Plugin Title')
00425 
00426             for finfo, rinfo in zip(found, _ZODB_ROLE_INFO):
00427                 self.assertEqual(finfo['id'], rinfo['role_id'])
00428                 self.assertEqual(finfo['title'], rinfo['title'])
00429                 self.assertEqual(finfo['description'], rinfo['description'])
00430                 for principal_id in rinfo['principals']:
00431                     roles = plugin._principal_roles[principal_id]
00432                     self.failUnless(rinfo['role_id'] in roles)

Definition at line 453 of file test_exportimport.py.

00453 
00454         def test_import_with_purge_wipes_existing_users(self):
00455 
00456             plugin = self._makePlugin('with_roles').__of__(self.root)
00457             plugin.title = 'Plugin Title'
00458 
00459             for r in _ZODB_ROLE_INFO:
00460                 plugin.addRole(r['role_id'], r['title'], r['description'])
00461                 for principal in r['principals']:
00462                     plugin.assignRoleToPrincipal(r['role_id'], principal)
00463 
00464             adapter = self._makeOne(plugin)
00465 
00466             context = DummyImportContext(plugin, purge=True)
00467             context._files['plugins/with_roles.xml'] = _EMPTY_ZODB_ROLES
00468 
00469             self.assertEqual(len(plugin._roles), len(_ZODB_ROLE_INFO))
00470             adapter.import_(context, 'plugins', False)
00471             self.assertEqual(len(plugin._roles), 0)
00472             self.assertEqual(plugin.title, None)
00473 
    class CookieAuthHelperExportImportTests(_TestBase):

Definition at line 433 of file test_exportimport.py.

00433 
00434         def test_import_without_purge_leaves_existing_users(self):
00435 
00436             plugin = self._makePlugin('with_roles').__of__(self.root)
00437             plugin.title = 'Plugin Title'
00438 
00439             for r in _ZODB_ROLE_INFO:
00440                 plugin.addRole(r['role_id'], r['title'], r['description'])
00441                 for principal in r['principals']:
00442                     plugin.assignRoleToPrincipal(r['role_id'], principal)
00443 
00444             adapter = self._makeOne(plugin)
00445 
00446             context = DummyImportContext(plugin, purge=False)
00447             context._files['plugins/with_roles.xml'] = _EMPTY_ZODB_ROLES
00448 
00449             self.assertEqual(len(plugin._roles), len(_ZODB_ROLE_INFO))
00450             adapter.import_(context, 'plugins', False)
00451             self.assertEqual(len(plugin._roles), len(_ZODB_ROLE_INFO))
00452             self.assertEqual(plugin.title, None)

Definition at line 343 of file test_exportimport.py.

00343 
00344         def test_listExportableItems(self):
00345             plugin = self._makePlugin('lEI').__of__(self.root)
00346             adapter = self._makeOne(plugin)
00347 
00348             self.assertEqual(len(adapter.listExportableItems()), 0)
00349             plugin.addRole('role_id', 'title', 'description')
00350             self.assertEqual(len(adapter.listExportableItems()), 0)


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