[CMF-checkins] SVN: CMF/trunk/CMFCore/tests/ Forward port test
cleanup / expansion from 2.0 branch.
Tres Seaver
tseaver at palladion.com
Fri Sep 8 13:50:11 EDT 2006
Log message for revision 70074:
Forward port test cleanup / expansion from 2.0 branch.
Changed:
U CMF/trunk/CMFCore/tests/fake_skins/fake_skin/test_props.props
U CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py
-=-
Modified: CMF/trunk/CMFCore/tests/fake_skins/fake_skin/test_props.props
===================================================================
--- CMF/trunk/CMFCore/tests/fake_skins/fake_skin/test_props.props 2006-09-08 17:46:16 UTC (rev 70073)
+++ CMF/trunk/CMFCore/tests/fake_skins/fake_skin/test_props.props 2006-09-08 17:50:10 UTC (rev 70074)
@@ -2,3 +2,9 @@
value1:string=one
value2:string=two
+an_int:int=42
+a_float:float=3.1415926
+a_boolean:boolean=False
+a_long:long=40000000000
+a_date:date=01/01/2001
+a_tokens:tokens=peter paul mary
Modified: CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py 2006-09-08 17:46:16 UTC (rev 70073)
+++ CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py 2006-09-08 17:50:10 UTC (rev 70074)
@@ -1,57 +1,88 @@
import unittest
-import Testing
-from os.path import join
-
-from OFS.Folder import Folder
-
-from Products.CMFCore.FSPropertiesObject import FSPropertiesObject
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import SecurityTest
+class FSPOTests(SecurityTest, FSDVTest):
-class FSPOMaker(FSDVTest):
+ def setUp( self ):
+ FSDVTest.setUp(self)
+ SecurityTest.setUp( self )
+ def tearDown( self ):
+ SecurityTest.tearDown( self )
+ FSDVTest.tearDown(self)
+
+ def _getTargetClass( self ):
+ from Products.CMFCore.FSPropertiesObject import FSPropertiesObject
+ return FSPropertiesObject
+
def _makeOne( self, id, filename ):
+ from os.path import join
path = join(self.skin_path_name, filename)
- return FSPropertiesObject( id, path )
+ return self._getTargetClass()( id, path )
+ def _makeContext( self, po_id, po_filename ):
+ from OFS.Folder import Folder
-class FSPropertiesObjectCustomizationTests(SecurityTest, FSPOMaker):
+ self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
+ skins = self.root.portal_skins
- def setUp( self ):
- FSPOMaker.setUp(self)
- SecurityTest.setUp( self )
+ skins._setObject( 'custom', Folder( 'custom' ) )
+ custom = skins.custom
- self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
- self.skins = self.root.portal_skins
+ skins._setObject( 'fsdir', Folder( 'fsdir' ) )
+ fsdir = skins.fsdir
- self.skins._setObject( 'custom', Folder( 'custom' ) )
- self.custom = self.skins.custom
+ fsdir._setObject( 'test_props', self._makeOne( po_id, po_filename ) )
+ fspo = fsdir.test_props
- self.skins._setObject( 'fsdir', Folder( 'fsdir' ) )
- self.fsdir = self.skins.fsdir
+ return custom, fsdir, fspo
- self.fsdir._setObject( 'test_props'
- , self._makeOne( 'test_props', 'test_props.props' ) )
+ def test__readFile( self ):
+ from DateTime.DateTime import DateTime
- self.fsPO = self.fsdir.test_props
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSPOMaker.tearDown(self)
+ self.assertEqual( fspo.getProperty( 'title' ), 'Test properties' )
+ self.assertEqual( fspo.getProperty( 'value1' ), 'one' )
+ self.assertEqual( fspo.getProperty( 'value2' ), 'two' )
+ self.assertEqual( fspo.getProperty( 'an_int' ), 42 )
+ self.assertEqual( fspo.getProperty( 'a_float' ), 3.1415926 )
+ self.assertEqual( fspo.getProperty( 'a_boolean' ), False )
+ self.assertEqual( fspo.getProperty( 'a_long' ), 40000000000 )
+ self.assertEqual( fspo.getProperty( 'a_date' )
+ , DateTime( '01/01/2001' ) )
+ self.assertEqual( fspo.getProperty( 'a_tokens' )
+ , [ 'peter', 'paul', 'mary' ] )
- def test_customize( self ):
+ def test__createZODBClone( self ):
- self.fsPO.manage_doCustomize( folder_path='custom' )
+ from OFS.Folder import Folder
- self.assertEqual( len( self.custom.objectIds() ), 1 )
- self.failUnless( 'test_props' in self.custom.objectIds() )
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
+ target = fspo._createZODBClone()
+ self.failUnless( isinstance( target, Folder ) )
+ for prop_id in fspo.propertyIds():
+ self.assertEqual( target.getProperty( prop_id )
+ , fspo.getProperty( prop_id ) )
+ def test_manage_doCustomize( self ):
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
+
+ fspo.manage_doCustomize( folder_path='custom' )
+
+ self.assertEqual( len( custom.objectIds() ), 1 )
+ self.failUnless( 'test_props' in custom.objectIds() )
+
+
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(FSPropertiesObjectCustomizationTests),
+ unittest.makeSuite( FSPOTests ),
))
if __name__ == '__main__':
More information about the CMF-checkins
mailing list