[CMF-checkins] CVS: CMF/CMFSetup/tests - common.py:1.7
test_actions.py:1.2 test_registry.py:1.8 test_rolemap.py:1.4
test_tool.py:1.10
Tres Seaver
tseaver at zope.com
Tue May 25 09:18:23 EDT 2004
Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv11332/tests
Modified Files:
common.py test_actions.py test_registry.py test_rolemap.py
test_tool.py
Log Message:
- interfaces.py, registry.py:
o Conform spelling of import / export methods to those being used
elsewhere.
- tool.py:
o Conform spelling of import / export methods to those being used
elsewhere.
o Take an optional encoding to 'setProfileDirectory', and propagate.
- tests/*.py:
o Add sample tests for explicitly passed encodings.
=== CMF/CMFSetup/tests/common.py 1.6 => 1.7 ===
--- CMF/CMFSetup/tests/common.py:1.6 Tue May 25 08:48:55 2004
+++ CMF/CMFSetup/tests/common.py Tue May 25 09:18:22 2004
@@ -125,16 +125,17 @@
class DummyImportContext:
- def __init__( self, site, purge=True ):
+ def __init__( self, site, purge=True, encoding=None ):
self._site = site
self._purge = purge
+ self._encoding = encoding
self._files = {}
def getSite( self ):
return self._site
def getEncoding( self ):
- return None
+ return self._encoding
def readDataFile( self, filename, subdir=None ):
=== CMF/CMFSetup/tests/test_actions.py 1.1 => 1.2 ===
--- CMF/CMFSetup/tests/test_actions.py:1.1 Mon May 24 18:43:51 2004
+++ CMF/CMFSetup/tests/test_actions.py Tue May 25 09:18:22 2004
@@ -216,6 +216,7 @@
</actions-tool>
"""
+
class Test_exportActionProviders( BaseRegistryTests
, _ActionSetup
):
@@ -324,6 +325,26 @@
self.failUnless( 'portal_actions' in atool.listActionProviders() )
context = DummyImportContext( site )
+ context._files[ 'actions.xml' ] = _NORMAL_EXPORT
+
+ from Products.CMFSetup.actions import importActionProviders
+ importActionProviders( context )
+
+ self.assertEqual( len( atool.listActionProviders() ), 3 )
+ self.failUnless( 'portal_foo' in atool.listActionProviders() )
+ self.failUnless( foo.listActions() )
+ self.failUnless( 'portal_bar' in atool.listActionProviders() )
+ self.failUnless( bar.listActions() )
+ self.failUnless( 'portal_actions' in atool.listActionProviders() )
+
+ def test_normal_encode_as_ascii( self ):
+
+ site = self._initSite( 1, 1 )
+ atool = site.portal_actions
+ foo = site.portal_foo
+ bar = site.portal_bar
+
+ context = DummyImportContext( site, encoding='ascii' )
context._files[ 'actions.xml' ] = _NORMAL_EXPORT
from Products.CMFSetup.actions import importActionProviders
=== CMF/CMFSetup/tests/test_registry.py 1.7 => 1.8 ===
--- CMF/CMFSetup/tests/test_registry.py:1.7 Sun May 23 14:57:39 2004
+++ CMF/CMFSetup/tests/test_registry.py Tue May 25 09:18:22 2004
@@ -430,15 +430,15 @@
self.assertEqual( len( incomplete ), 1 )
self.failUnless( ( 'two', 'four' ) in incomplete )
- def test_export_empty( self ):
+ def test_generateXML_empty( self ):
registry = self._makeOne().__of__( self.root )
- xml = registry.exportAsXML()
+ xml = registry.generateXML()
- self._compareDOM( registry.exportAsXML(), _EMPTY_IMPORT_XML )
+ self._compareDOM( registry.generateXML(), _EMPTY_IMPORT_XML )
- def test_export_single( self ):
+ def test_generateXML_single( self ):
registry = self._makeOne().__of__( self.root )
@@ -450,9 +450,9 @@
, description='One small step'
)
- self._compareDOM( registry.exportAsXML(), _SINGLE_IMPORT_XML )
+ self._compareDOM( registry.generateXML(), _SINGLE_IMPORT_XML )
- def test_export_ordered( self ):
+ def test_generateXML_ordered( self ):
registry = self._makeOne().__of__( self.root )
@@ -480,9 +480,9 @@
, description='Gimme three steps'
)
- self._compareDOM( registry.exportAsXML(), _ORDERED_IMPORT_XML )
+ self._compareDOM( registry.generateXML(), _ORDERED_IMPORT_XML )
- def test_import_empty( self ):
+ def test_parseXML_empty( self ):
registry = self._makeOne().__of__( self.root )
@@ -493,13 +493,13 @@
, description='One small step'
)
- registry.importFromXML( _EMPTY_IMPORT_XML )
+ registry.parseXML( _EMPTY_IMPORT_XML )
self.assertEqual( len( registry.listSteps() ), 0 )
self.assertEqual( len( registry.listStepMetadata() ), 0 )
self.assertEqual( len( registry.sortSteps() ), 0 )
- def test_import_single( self ):
+ def test_parseXML_single( self ):
registry = self._makeOne().__of__( self.root )
@@ -511,7 +511,7 @@
, description='Texas two step'
)
- registry.importFromXML( _SINGLE_IMPORT_XML )
+ registry.parseXML( _SINGLE_IMPORT_XML )
self.assertEqual( len( registry.listSteps() ), 1 )
self.failUnless( 'one' in registry.listSteps() )
@@ -524,11 +524,11 @@
self.assertEqual( info[ 'title' ], 'One Step' )
self.failUnless( 'One small step' in info[ 'description' ] )
- def test_import_ordered( self ):
+ def test_parseXML_ordered( self ):
registry = self._makeOne().__of__( self.root )
- registry.importFromXML( _ORDERED_IMPORT_XML )
+ registry.parseXML( _ORDERED_IMPORT_XML )
self.assertEqual( len( registry.listSteps() ), 3 )
self.failUnless( 'one' in registry.listSteps() )
@@ -687,75 +687,96 @@
registry.registerStep( 'one', ONE_FUNC )
self.assertRaises( KeyError, registry.registerStep, 'one', TWO_FUNC )
- def test_export_empty( self ):
+ def test_generateXML_empty( self ):
registry = self._makeOne().__of__( self.root )
- xml = registry.exportAsXML()
+ xml = registry.generateXML()
- self._compareDOM( registry.exportAsXML(), _EMPTY_EXPORT_XML )
+ self._compareDOM( registry.generateXML(), _EMPTY_EXPORT_XML )
- def test_export_single( self ):
+ def test_generateXML_single( self ):
registry = self._makeOne().__of__( self.root )
registry.registerStep( id='one'
- , handler=ONE_FUNC
- , title='One Step'
- , description='One small step'
- )
+ , handler=ONE_FUNC
+ , title='One Step'
+ , description='One small step'
+ )
- self._compareDOM( registry.exportAsXML(), _SINGLE_EXPORT_XML )
+ self._compareDOM( registry.generateXML(), _SINGLE_EXPORT_XML )
- def test_export_ordered( self ):
+ def test_generateXML_ordered( self ):
registry = self._makeOne().__of__( self.root )
registry.registerStep( id='one'
- , handler=ONE_FUNC
- , title='One Step'
- , description='One small step'
- )
+ , handler=ONE_FUNC
+ , title='One Step'
+ , description='One small step'
+ )
registry.registerStep( id='two'
- , handler=TWO_FUNC
- , title='Two Steps'
- , description='Texas two step'
- )
+ , handler=TWO_FUNC
+ , title='Two Steps'
+ , description='Texas two step'
+ )
registry.registerStep( id='three'
- , handler=THREE_FUNC
- , title='Three Steps'
- , description='Gimme three steps'
- )
+ , handler=THREE_FUNC
+ , title='Three Steps'
+ , description='Gimme three steps'
+ )
- self._compareDOM( registry.exportAsXML(), _ORDERED_EXPORT_XML )
+ self._compareDOM( registry.generateXML(), _ORDERED_EXPORT_XML )
- def test_import_empty( self ):
+ def test_parseXML_empty( self ):
registry = self._makeOne().__of__( self.root )
registry.registerStep( id='one'
- , handler=ONE_FUNC
- , description='One small step'
- )
+ , handler=ONE_FUNC
+ , description='One small step'
+ )
- registry.importFromXML( _EMPTY_EXPORT_XML )
+ registry.parseXML( _EMPTY_EXPORT_XML )
self.assertEqual( len( registry.listSteps() ), 0 )
self.assertEqual( len( registry.listStepMetadata() ), 0 )
- def test_import_single( self ):
+ def test_parseXML_single( self ):
+
+ registry = self._makeOne().__of__( self.root )
+
+ registry.registerStep( id='two'
+ , handler=TWO_FUNC
+ , title='Two Steps'
+ , description='Texas two step'
+ )
+
+ registry.parseXML( _SINGLE_EXPORT_XML )
+
+ self.assertEqual( len( registry.listSteps() ), 1 )
+ self.failUnless( 'one' in registry.listSteps() )
+
+ info = registry.getStepMetadata( 'one' )
+ self.assertEqual( info[ 'id' ], 'one' )
+ self.assertEqual( info[ 'handler' ], ONE_FUNC_NAME )
+ self.assertEqual( info[ 'title' ], 'One Step' )
+ self.failUnless( 'One small step' in info[ 'description' ] )
+
+ def test_parseXML_single_as_ascii( self ):
registry = self._makeOne().__of__( self.root )
registry.registerStep( id='two'
- , handler=TWO_FUNC
- , title='Two Steps'
- , description='Texas two step'
- )
+ , handler=TWO_FUNC
+ , title='Two Steps'
+ , description='Texas two step'
+ )
- registry.importFromXML( _SINGLE_EXPORT_XML )
+ registry.parseXML( _SINGLE_EXPORT_XML, encoding='ascii' )
self.assertEqual( len( registry.listSteps() ), 1 )
self.failUnless( 'one' in registry.listSteps() )
@@ -766,11 +787,11 @@
self.assertEqual( info[ 'title' ], 'One Step' )
self.failUnless( 'One small step' in info[ 'description' ] )
- def test_import_ordered( self ):
+ def test_parseXML_ordered( self ):
registry = self._makeOne().__of__( self.root )
- registry.importFromXML( _ORDERED_EXPORT_XML )
+ registry.parseXML( _ORDERED_EXPORT_XML )
self.assertEqual( len( registry.listSteps() ), 3 )
self.failUnless( 'one' in registry.listSteps() )
=== CMF/CMFSetup/tests/test_rolemap.py 1.3 => 1.4 ===
--- CMF/CMFSetup/tests/test_rolemap.py:1.3 Sun May 23 23:12:10 2004
+++ CMF/CMFSetup/tests/test_rolemap.py Tue May 25 09:18:22 2004
@@ -718,6 +718,43 @@
self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
+ def test_unacquired_permission_added_role_skip_purge_encode_ascii( self ):
+
+ ACI = 'Access contents information'
+ VIEW = 'View'
+
+ self.root.site = Folder( id='site' )
+ site = self.root.site
+ site.manage_permission( VIEW, () )
+
+ existing_allowed = [ x[ 'name' ]
+ for x in site.rolesOfPermission( ACI )
+ if x[ 'selected' ] ]
+
+ self.assertEqual( existing_allowed, [ 'Manager' ] )
+
+ self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
+ self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
+
+ self.failIf( site._has_user_defined_role( 'ZZZ' ) )
+
+ context = DummyImportContext( site, False, encoding='ascii' )
+ context._files[ 'rolemap.xml' ] = _COMBINED_EXPORT
+
+ from Products.CMFSetup.rolemap import importRolemap
+ importRolemap( context )
+
+ self.failUnless( site._has_user_defined_role( 'ZZZ' ) )
+
+ new_allowed = [ x[ 'name' ]
+ for x in site.rolesOfPermission( ACI )
+ if x[ 'selected' ] ]
+
+ self.assertEqual( new_allowed, [ 'Manager', 'Owner', 'ZZZ' ] )
+
+ self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
+ self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
+
def test_suite():
return unittest.TestSuite((
=== CMF/CMFSetup/tests/test_tool.py 1.9 => 1.10 ===
--- CMF/CMFSetup/tests/test_tool.py:1.9 Mon May 24 15:53:56 2004
+++ CMF/CMFSetup/tests/test_tool.py Tue May 25 09:18:22 2004
@@ -184,6 +184,28 @@
, 'Products.CMFSetup.tests.common.dummy_handler' )
self.assertEqual( export_registry.getStep( 'one' ), dummy_handler )
+ def test_setProfileDirectory_relative_encode_as_ascii( self ):
+
+ import Products.CMFSetup
+ from common import dummy_handler
+
+ _PATH = 'tests/default_profile'
+ _PRODUCT_PATH = os.path.split( Products.CMFSetup.__file__ )[0]
+ _FQPATH = os.path.join( _PRODUCT_PATH, _PATH )
+
+ tool = self._makeOne()
+ tool.setProfileDirectory( _PATH, 'CMFSetup', encoding='ascii' )
+
+ import_registry = tool.getImportStepRegistry()
+ self.assertEqual( len( import_registry.listSteps() ), 1 )
+ self.failUnless( 'one' in import_registry.listSteps() )
+ self.assertEqual( import_registry.getStep( 'one' ), dummy_handler )
+
+ export_registry = tool.getExportStepRegistry()
+ self.assertEqual( len( export_registry.listSteps() ), 1 )
+ self.failUnless( 'one' in import_registry.listSteps() )
+ self.assertEqual( export_registry.getStep( 'one' ), dummy_handler )
+
def test_setProfileDirectory_relative_invalid_product( self ):
_PATH = 'tests/default_profile'
More information about the CMF-checkins
mailing list