Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
GenericSetup.tests.test_rolemap.Test_importRolemap Class Reference
Inheritance diagram for GenericSetup.tests.test_rolemap.Test_importRolemap:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.tests.test_rolemap.Test_importRolemap:
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_acquired_permission_explicit_purge
def test_acquired_permission_no_purge
def test_unacquired_permission_explicit_purge
def test_unacquired_permission_skip_purge
def test_unacquired_permission_added_role_explicit_purge
def test_unacquired_permission_added_role_skip_purge
def test_unacquired_permission_added_role_skip_purge_encode_ascii

Static Public Attributes

 layer = ExportImportZCMLLayer

Detailed Description

Definition at line 468 of file test_rolemap.py.


Member Function Documentation

Definition at line 538 of file test_rolemap.py.

00538 
00539     def test_acquired_permission_explicit_purge( self ):
00540 
00541         ACI = 'Access contents information'
00542         VIEW = 'View'
00543 
00544         self.app.site = Folder(id='site')
00545         site = self.app.site
00546         site.manage_permission( ACI, () )
00547         site.manage_permission( VIEW, () )
00548 
00549         existing_allowed = [ x[ 'name' ]
00550                                 for x in site.rolesOfPermission( ACI )
00551                                 if x[ 'selected' ] ]
00552 
00553         self.assertEqual( existing_allowed, [] )
00554 
00555         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00556         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00557 
00558         context = DummyImportContext( site, True )
00559         context._files[ 'rolemap.xml' ] = _ACQUIRED_EXPORT
00560 
00561         from Products.GenericSetup.rolemap import importRolemap
00562         importRolemap( context )
00563 
00564         new_allowed = [ x[ 'name' ]
00565                            for x in site.rolesOfPermission( ACI )
00566                            if x[ 'selected' ] ]
00567 
00568         self.assertEqual( new_allowed, [ 'Manager', 'Owner' ] )
00569 
00570         # ACI is overwritten by XML, but VIEW was purged
00571         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00572         self.failUnless( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:

Definition at line 573 of file test_rolemap.py.

00573 
00574     def test_acquired_permission_no_purge( self ):
00575 
00576         ACI = 'Access contents information'
00577         VIEW = 'View'
00578 
00579         self.app.site = Folder(id='site')
00580         site = self.app.site
00581         site.manage_permission( ACI, () )
00582         site.manage_permission( VIEW, () )
00583 
00584         existing_allowed = [ x[ 'name' ]
00585                                 for x in site.rolesOfPermission( ACI )
00586                                 if x[ 'selected' ] ]
00587 
00588         self.assertEqual( existing_allowed, [] )
00589 
00590         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00591 
00592         context = DummyImportContext( site, False )
00593         context._files[ 'rolemap.xml' ] = _ACQUIRED_EXPORT
00594 
00595         from Products.GenericSetup.rolemap import importRolemap
00596         importRolemap( context )
00597 
00598         new_allowed = [ x[ 'name' ]
00599                            for x in site.rolesOfPermission( ACI )
00600                            if x[ 'selected' ] ]
00601 
00602         self.assertEqual( new_allowed, [ 'Manager', 'Owner' ] )
00603 
00604         # ACI is overwritten by XML, but VIEW is not
00605         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00606         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:

Definition at line 472 of file test_rolemap.py.

00472 
00473     def test_empty_default_purge( self ):
00474 
00475         self.app.site = Folder(id='site')
00476         site = self.app.site
00477         original_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00478         modified_roles = original_roles[:]
00479         modified_roles.append( 'ZZZ' )
00480         site.__ac_roles__ = modified_roles
00481 
00482         context = DummyImportContext( site )
00483         context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT
00484 
00485         from Products.GenericSetup.rolemap import importRolemap
00486         importRolemap( context )
00487 
00488         new_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00489 
00490         original_roles.sort()
00491         new_roles.sort()
00492 
00493         self.assertEqual( original_roles, new_roles )

Here is the call graph for this function:

Definition at line 494 of file test_rolemap.py.

00494 
00495     def test_empty_explicit_purge( self ):
00496 
00497         self.app.site = Folder(id='site')
00498         site = self.app.site
00499         original_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00500         modified_roles = original_roles[:]
00501         modified_roles.append( 'ZZZ' )
00502         site.__ac_roles__ = modified_roles
00503 
00504         context = DummyImportContext( site, True )
00505         context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT
00506 
00507         from Products.GenericSetup.rolemap import importRolemap
00508         importRolemap( context )
00509 
00510         new_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00511 
00512         original_roles.sort()
00513         new_roles.sort()
00514 
00515         self.assertEqual( original_roles, new_roles )

Here is the call graph for this function:

Definition at line 516 of file test_rolemap.py.

00516 
00517     def test_empty_skip_purge( self ):
00518 
00519         self.app.site = Folder(id='site')
00520         site = self.app.site
00521         original_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00522         modified_roles = original_roles[:]
00523         modified_roles.append( 'ZZZ' )
00524         site.__ac_roles__ = modified_roles
00525 
00526         context = DummyImportContext( site, False )
00527         context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT
00528 
00529         from Products.GenericSetup.rolemap import importRolemap
00530         importRolemap( context )
00531 
00532         new_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
00533 
00534         modified_roles.sort()
00535         new_roles.sort()
00536 
00537         self.assertEqual( modified_roles, new_roles )

Here is the call graph for this function:

Definition at line 673 of file test_rolemap.py.

00673 
00674     def test_unacquired_permission_added_role_explicit_purge( self ):
00675 
00676         ACI = 'Access contents information'
00677         VIEW = 'View'
00678 
00679         self.app.site = Folder(id='site')
00680         site = self.app.site
00681         site.manage_permission( VIEW, () )
00682 
00683         existing_allowed = [ x[ 'name' ]
00684                                 for x in site.rolesOfPermission( ACI )
00685                                 if x[ 'selected' ] ]
00686 
00687         self.assertEqual( existing_allowed, [ 'Manager' ] )
00688 
00689         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00690         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00691 
00692         self.failIf( site._has_user_defined_role( 'ZZZ' ) )
00693 
00694         context = DummyImportContext( site, True )
00695         context._files[ 'rolemap.xml' ] = _COMBINED_EXPORT
00696 
00697         from Products.GenericSetup.rolemap import importRolemap
00698         importRolemap( context )
00699 
00700         self.failUnless( site._has_user_defined_role( 'ZZZ' ) )
00701 
00702         new_allowed = [ x[ 'name' ]
00703                            for x in site.rolesOfPermission( ACI )
00704                            if x[ 'selected' ] ]
00705 
00706         self.assertEqual( new_allowed, [ 'Manager', 'Owner', 'ZZZ' ] )
00707 
00708         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00709         self.failUnless( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:

Definition at line 710 of file test_rolemap.py.

00710 
00711     def test_unacquired_permission_added_role_skip_purge( self ):
00712 
00713         ACI = 'Access contents information'
00714         VIEW = 'View'
00715 
00716         self.app.site = Folder(id='site')
00717         site = self.app.site
00718         site.manage_permission( VIEW, () )
00719 
00720         existing_allowed = [ x[ 'name' ]
00721                                 for x in site.rolesOfPermission( ACI )
00722                                 if x[ 'selected' ] ]
00723 
00724         self.assertEqual( existing_allowed, [ 'Manager' ] )
00725 
00726         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00727         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00728 
00729         self.failIf( site._has_user_defined_role( 'ZZZ' ) )
00730 
00731         context = DummyImportContext( site, False )
00732         context._files[ 'rolemap.xml' ] = _COMBINED_EXPORT
00733 
00734         from Products.GenericSetup.rolemap import importRolemap
00735         importRolemap( context )
00736 
00737         self.failUnless( site._has_user_defined_role( 'ZZZ' ) )
00738 
00739         new_allowed = [ x[ 'name' ]
00740                            for x in site.rolesOfPermission( ACI )
00741                            if x[ 'selected' ] ]
00742 
00743         self.assertEqual( new_allowed, [ 'Manager', 'Owner', 'ZZZ' ] )
00744 
00745         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00746         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:

Definition at line 747 of file test_rolemap.py.

00747 
00748     def test_unacquired_permission_added_role_skip_purge_encode_ascii( self ):
00749 
00750         ACI = 'Access contents information'
00751         VIEW = 'View'
00752 
00753         self.app.site = Folder(id='site')
00754         site = self.app.site
00755         site.manage_permission( VIEW, () )
00756 
00757         existing_allowed = [ x[ 'name' ]
00758                                 for x in site.rolesOfPermission( ACI )
00759                                 if x[ 'selected' ] ]
00760 
00761         self.assertEqual( existing_allowed, [ 'Manager' ] )
00762 
00763         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00764         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00765 
00766         self.failIf( site._has_user_defined_role( 'ZZZ' ) )
00767 
00768         context = DummyImportContext( site, False, encoding='ascii' )
00769         context._files[ 'rolemap.xml' ] = _COMBINED_EXPORT
00770 
00771         from Products.GenericSetup.rolemap import importRolemap
00772         importRolemap( context )
00773 
00774         self.failUnless( site._has_user_defined_role( 'ZZZ' ) )
00775 
00776         new_allowed = [ x[ 'name' ]
00777                            for x in site.rolesOfPermission( ACI )
00778                            if x[ 'selected' ] ]
00779 
00780         self.assertEqual( new_allowed, [ 'Manager', 'Owner', 'ZZZ' ] )
00781 
00782         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00783         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00784 

Here is the call graph for this function:

Definition at line 607 of file test_rolemap.py.

00607 
00608     def test_unacquired_permission_explicit_purge( self ):
00609 
00610         ACI = 'Access contents information'
00611         VIEW = 'View'
00612 
00613         self.app.site = Folder(id='site')
00614         site = self.app.site
00615         site.manage_permission( VIEW, () )
00616 
00617         existing_allowed = [ x[ 'name' ]
00618                                 for x in site.rolesOfPermission( ACI )
00619                                 if x[ 'selected' ] ]
00620 
00621         self.assertEqual( existing_allowed, [ 'Manager' ] )
00622 
00623         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00624         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00625 
00626         context = DummyImportContext( site, True )
00627         context._files[ 'rolemap.xml' ] = _UNACQUIRED_EXPORT
00628 
00629         from Products.GenericSetup.rolemap import importRolemap
00630         importRolemap( context )
00631 
00632         new_allowed = [ x[ 'name' ]
00633                            for x in site.rolesOfPermission( ACI )
00634                            if x[ 'selected' ] ]
00635 
00636         self.assertEqual( new_allowed, [ 'Manager', 'Owner' ] )
00637 
00638         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00639         self.failUnless( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:

Definition at line 640 of file test_rolemap.py.

00640 
00641     def test_unacquired_permission_skip_purge( self ):
00642 
00643         ACI = 'Access contents information'
00644         VIEW = 'View'
00645 
00646         self.app.site = Folder(id='site')
00647         site = self.app.site
00648         site.manage_permission( VIEW, () )
00649 
00650         existing_allowed = [ x[ 'name' ]
00651                                 for x in site.rolesOfPermission( ACI )
00652                                 if x[ 'selected' ] ]
00653 
00654         self.assertEqual( existing_allowed, [ 'Manager' ] )
00655 
00656         self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
00657         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
00658 
00659         context = DummyImportContext( site, False )
00660         context._files[ 'rolemap.xml' ] = _UNACQUIRED_EXPORT
00661 
00662         from Products.GenericSetup.rolemap import importRolemap
00663         importRolemap( context )
00664 
00665         new_allowed = [ x[ 'name' ]
00666                            for x in site.rolesOfPermission( ACI )
00667                            if x[ 'selected' ] ]
00668 
00669         self.assertEqual( new_allowed, [ 'Manager', 'Owner' ] )
00670 
00671         self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
00672         self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )

Here is the call graph for this function:


Member Data Documentation

Definition at line 470 of file test_rolemap.py.


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