[CMF-checkins] CVS: CMF/CMFSetup/tests - test_tool.py:1.3
Tres Seaver
tseaver at zope.com
Sun May 23 17:05:09 EDT 2004
Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv21820/tests
Modified Files:
test_tool.py
Log Message:
- context.py:
o Repair lamosity.
- interfaces.py:
o Finish rename from 'setupStep' to 'importStep'.
- tool.py:
o Implement and test 'runImportStep'.
=== CMF/CMFSetup/tests/test_tool.py 1.2 => 1.3 ===
--- CMF/CMFSetup/tests/test_tool.py:1.2 Sun May 23 16:31:43 2004
+++ CMF/CMFSetup/tests/test_tool.py Sun May 23 17:05:08 2004
@@ -24,6 +24,17 @@
return self._getTargetClass()( *args, **kw )
+ def _makeSite( self, title ):
+
+ from OFS.Folder import Folder
+
+ site = Folder()
+ site._setId( 'site' )
+ site.title = title
+
+ self.root._setObject( 'site', site )
+ return self.root._getOb( 'site' )
+
def test_empty( self ):
tool = self._makeOne()
@@ -176,6 +187,117 @@
self.assertRaises( ValueError
, tool.setProfileDirectory, _PATH, 'NonesuchProduct' )
+ def test_runImportStep_nonesuch( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+
+ self.assertRaises( ValueError, tool.runImportStep, 'nonesuch' )
+
+ def test_runImportStep_simple( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'simple', '1', _uppercaseSiteTitle )
+
+ message = tool.runImportStep( 'simple' )
+
+ self.assertEqual( message, 'Updated title' )
+ self.assertEqual( site.title, TITLE.upper() )
+
+ def test_runImportStep_dependencies( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'dependable', '1', _underscoreSiteTitle )
+ registry.registerStep( 'dependent', '1'
+ , _uppercaseSiteTitle, ( 'dependable', ) )
+
+ message = tool.runImportStep( 'dependent' )
+
+ def test_runImportStep_skip_dependencies( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'dependable', '1', _underscoreSiteTitle )
+ registry.registerStep( 'dependent', '1'
+ , _uppercaseSiteTitle, ( 'dependable', ) )
+
+ message = tool.runImportStep( 'dependent', run_dependencies=False )
+
+ self.assertEqual( message, 'Updated title' )
+ self.assertEqual( site.title, TITLE.upper() )
+
+ def test_runImportStep_default_purge( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'purging', '1', _purgeIfRequired )
+
+ message = tool.runImportStep( 'purging' )
+
+ self.assertEqual( message, 'Purged' )
+
+ def test_runImportStep_explicit_purge( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'purging', '1', _purgeIfRequired )
+
+ message = tool.runImportStep( 'purging', purge_old=True )
+
+ self.assertEqual( message, 'Purged' )
+
+ def test_runImportStep_skip_purge( self ):
+
+ TITLE = 'original title'
+ site = self._makeSite( TITLE )
+
+ tool = self._makeOne().__of__( site )
+ registry = tool.getImportStepRegistry()
+ registry.registerStep( 'purging', '1', _purgeIfRequired )
+
+ message = tool.runImportStep( 'purging', purge_old=False )
+
+ self.assertEqual( message, 'Unpurged' )
+
+def _underscoreSiteTitle( context ):
+
+ site = context.getSite()
+ site.title = site.title.replace( ' ', '_' )
+ return 'Updated title'
+
+def _uppercaseSiteTitle( context ):
+
+ site = context.getSite()
+ site.title = site.title.upper()
+ return 'Updated title'
+
+def _purgeIfRequired( context ):
+
+ site = context.getSite()
+ purged = site.purged = context.shouldPurge()
+ return purged and 'Purged' or 'Unpurged'
def test_suite():
return unittest.TestSuite((
More information about the CMF-checkins
mailing list