Back to index

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


Member Function Documentation

Definition at line 1001 of file test_exportimport.py.

01001 
01002         def _getTargetClass(self):
01003             from Products.PluggableAuthService.plugins.exportimport \
01004                 import DynamicGroupsPluginExportImport
01005             return DynamicGroupsPluginExportImport

Definition at line 1006 of file test_exportimport.py.

01006 
01007         def _makePlugin(self, id, *args, **kw):
01008             from Products.PluggableAuthService.plugins.DynamicGroupsPlugin \
01009                 import DynamicGroupsPlugin
01010 
01011             return DynamicGroupsPlugin(id, *args, **kw)

Here is the caller graph for this function:

Definition at line 1020 of file test_exportimport.py.

01020 
01021         def test__getExportInfo_empty(self):
01022             plugin = self._makePlugin('empty', None).__of__(self.root)
01023             adapter = self._makeOne(plugin)
01024 
01025             info = adapter._getExportInfo()
01026             self.assertEqual(info['title'], None)
01027             self.assertEqual(len(info['groups']), 0)

Definition at line 1041 of file test_exportimport.py.

01041 
01042         def test__getExportInfo_with_groups(self):
01043 
01044             plugin = self._makePlugin('with_groups').__of__(self.root)
01045             plugin.title = 'Plugin Title'
01046 
01047             for g in _DYNAMIC_GROUP_INFO:
01048                 plugin.addGroup(g['group_id'],
01049                                 g['predicate'],
01050                                 g['title'],
01051                                 g['description'],
01052                                 g['active'],
01053                                )
01054 
01055             adapter = self._makeOne(plugin)
01056 
01057             info = adapter._getExportInfo()
01058             self.assertEqual(info['title'], 'Plugin Title')
01059             self.assertEqual(len(info['groups']), len(_DYNAMIC_GROUP_INFO))
01060 
01061             for x, y in zip(info['groups'], _DYNAMIC_GROUP_INFO):
01062                 self.assertEqual(x, y)

Definition at line 1028 of file test_exportimport.py.

01028 
01029         def test_export_empty(self):
01030             plugin = self._makePlugin('empty', None).__of__(self.root)
01031             adapter = self._makeOne(plugin)
01032 
01033             context = DummyExportContext(plugin)
01034             adapter.export(context, 'plugins', False)
01035 
01036             self.assertEqual( len( context._wrote ), 1 )
01037             filename, text, content_type = context._wrote[ 0 ]
01038             self.assertEqual( filename, 'plugins/empty.xml' )
01039             self._compareDOM( text, _EMPTY_DYNAMIC_GROUPS )
01040             self.assertEqual( content_type, 'text/xml' )

Definition at line 1063 of file test_exportimport.py.

01063 
01064         def test_export_with_groups(self):
01065 
01066             plugin = self._makePlugin('with_groups').__of__(self.root)
01067             plugin.title = 'Plugin Title'
01068 
01069             for g in _DYNAMIC_GROUP_INFO:
01070                 plugin.addGroup(g['group_id'],
01071                                 g['predicate'],
01072                                 g['title'],
01073                                 g['description'],
01074                                 g['active'],
01075                                )
01076 
01077             adapter = self._makeOne(plugin)
01078             context = DummyExportContext(plugin)
01079             adapter.export(context, 'plugins', False)
01080 
01081             self.assertEqual( len(context._wrote), 1)
01082             filename, text, content_type = context._wrote[ 0 ]
01083             self.assertEqual(filename, 'plugins/with_groups.xml')
01084             self._compareDOM(text, _FILLED_DYNAMIC_GROUPS)
01085             self.assertEqual(content_type, 'text/xml')

Definition at line 1086 of file test_exportimport.py.

01086 
01087         def test_import_empty(self):
01088             plugin = self._makePlugin('empty', None).__of__(self.root)
01089             adapter = self._makeOne(plugin)
01090 
01091             context = DummyImportContext(plugin, encoding='ascii')
01092             context._files['plugins/empty.xml'] = _FILLED_DYNAMIC_GROUPS
01093             self.assertEqual(plugin.title, None)
01094 
01095             adapter.import_(context, 'plugins', False)
01096 
01097             found = plugin.listGroupInfo()
01098             self.assertEqual(len(found), len(_DYNAMIC_GROUP_INFO))
01099             self.assertEqual(plugin.title, 'Plugin Title')
01100 
01101             for finfo, ginfo in zip(found, _DYNAMIC_GROUP_INFO):
01102                 self.assertEqual(finfo['id'], ginfo['group_id'])
01103                 self.assertEqual(finfo['predicate'], ginfo['predicate'])
01104                 self.assertEqual(finfo['title'], ginfo['title'])
01105                 self.assertEqual(finfo['description'], ginfo['description'])
01106                 self.assertEqual(finfo['active'], ginfo['active'])

Definition at line 1132 of file test_exportimport.py.

01132 
01133         def test_import_with_purge_wipes_existing_users(self):
01134 
01135             plugin = self._makePlugin('with_groups').__of__(self.root)
01136             plugin.title = 'Plugin Title'
01137 
01138             for g in _DYNAMIC_GROUP_INFO:
01139                 plugin.addGroup(g['group_id'],
01140                                 g['predicate'],
01141                                 g['title'],
01142                                 g['description'],
01143                                 g['active'],
01144                                )
01145 
01146             adapter = self._makeOne(plugin)
01147 
01148             context = DummyImportContext(plugin, purge=True)
01149             context._files['plugins/with_groups.xml'] = _EMPTY_DYNAMIC_GROUPS
01150 
01151             self.assertEqual(len(plugin.listGroupIds()),
01152                              len(_DYNAMIC_GROUP_INFO))
01153             adapter.import_(context, 'plugins', False)
01154             self.assertEqual(len(plugin.listGroupIds()), 0)
01155             self.assertEqual(plugin.title, None)
01156 
    def test_suite():

Definition at line 1107 of file test_exportimport.py.

01107 
01108         def test_import_without_purge_leaves_existing_users(self):
01109 
01110             plugin = self._makePlugin('with_groups').__of__(self.root)
01111             plugin.title = 'Plugin Title'
01112 
01113             for g in _DYNAMIC_GROUP_INFO:
01114                 plugin.addGroup(g['group_id'],
01115                                 g['predicate'],
01116                                 g['title'],
01117                                 g['description'],
01118                                 g['active'],
01119                                )
01120 
01121             adapter = self._makeOne(plugin)
01122 
01123             context = DummyImportContext(plugin, purge=False)
01124             context._files['plugins/with_groups.xml'] = _EMPTY_DYNAMIC_GROUPS
01125 
01126             self.assertEqual(len(plugin.listGroupIds()),
01127                              len(_DYNAMIC_GROUP_INFO))
01128             adapter.import_(context, 'plugins', False)
01129             self.assertEqual(len(plugin.listGroupIds()),
01130                              len(_DYNAMIC_GROUP_INFO))
01131             self.assertEqual(plugin.title, None)

Definition at line 1012 of file test_exportimport.py.

01012 
01013         def test_listExportableItems(self):
01014             plugin = self._makePlugin('lEI').__of__(self.root)
01015             adapter = self._makeOne(plugin)
01016 
01017             self.assertEqual(len(adapter.listExportableItems()), 0)
01018             plugin.addGroup('group_id', 'python:1', 'Group Title' )
01019             self.assertEqual(len(adapter.listExportableItems()), 0)


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