[CMF-checkins] CVS: Products/CMFCore/tests - test_FSZSQLMethod.py:1.3

Jens Vagelpohl jens at dataflake.org
Wed May 4 16:35:58 EDT 2005


Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv7408/CMFCore/tests

Modified Files:
	test_FSZSQLMethod.py 
Log Message:
- CMFCore.FSZSQLMethod: Add the forgotten setting to allow simple
  direct traversal for ZSQL methods to the list of settings recognized
  and applied by FSZSQLMethods during instantiation and customization.
  (http://www.zope.org/Collectors/CMF/350)


=== Products/CMFCore/tests/test_FSZSQLMethod.py 1.2 => 1.3 ===
--- Products/CMFCore/tests/test_FSZSQLMethod.py:1.2	Wed Apr  6 07:21:14 2005
+++ Products/CMFCore/tests/test_FSZSQLMethod.py	Wed May  4 16:35:28 2005
@@ -1,11 +1,24 @@
 from unittest import TestSuite, makeSuite, main
+from os.path import join
+
 import Testing
 import Zope
 Zope.startup()
 
+from OFS.Folder import Folder
+
 from Products.CMFCore.FSZSQLMethod import FSZSQLMethod
+from Products.CMFCore.FSMetadata import FSMetadata
 from Products.CMFCore.tests.base.testcase import FSDVTest
+from Products.CMFCore.tests.base.testcase import SecurityTest
 
+class FSZSQLMaker(FSDVTest):
+
+    def _makeOne( self, id, filename ):
+        path = join(self.skin_path_name, filename)
+        metadata = FSMetadata(path)
+        metadata.read()
+        return FSZSQLMethod( id, path, properties=metadata.getProperties() )
 
 class FSZSQLMethodTests( FSDVTest ):
 
@@ -24,11 +37,57 @@
         self.assertEqual(zsql.class_name_, 'MyRecord')
         self.assertEqual(zsql.class_file_, 'CMFCore.TestRecord')
         self.assertEqual(zsql.connection_hook, 'MyHook')
+        self.failIf(zsql.allow_simple_one_argument_traversal is None)
+
+
+class FSZSQLMethodCustomizationTests(SecurityTest, FSZSQLMaker):
+
+    def setUp( self ):
+        FSZSQLMaker.setUp(self)
+        SecurityTest.setUp( self )
+
+        self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
+        self.skins = self.root.portal_skins
+
+        self.skins._setObject( 'custom', Folder( 'custom' ) )
+        self.custom = self.skins.custom
+
+        self.skins._setObject( 'fsdir', Folder( 'fsdir' ) )
+        self.fsdir = self.skins.fsdir
+
+        self.fsdir._setObject( 'testsql'
+                             , self._makeOne( 'testsql', 'testsql.zsql' ) )
+
+        self.fsZSQL = self.fsdir.testsql
+
+    def test_customize( self ):
+
+        self.fsZSQL.manage_doCustomize( folder_path='custom' )
+
+        self.assertEqual( len( self.custom.objectIds() ), 1 )
+        self.failUnless( 'testsql' in self.custom.objectIds() )   
+
+    def test_customize_properties(self):
+        # Make sure all properties are coming across
+        self.fsZSQL.manage_doCustomize( folder_path='custom' )
+        zsql = self.custom.testsql
+
+        self.assertEqual(zsql.title, 'This is a title')
+        self.assertEqual(zsql.connection_id, 'testconn')
+        self.assertEqual(zsql.arguments_src, 'id')
+        self.assertEqual(zsql.max_rows_, 1000)
+        self.assertEqual(zsql.max_cache_, 100)
+        self.assertEqual(zsql.cache_time_, 10)
+        self.assertEqual(zsql.class_name_, 'MyRecord')
+        self.assertEqual(zsql.class_file_, 'CMFCore.TestRecord')
+        self.assertEqual(zsql.connection_hook, 'MyHook')
+        self.failIf(zsql.allow_simple_one_argument_traversal is None)
 
 
 def test_suite():
     return TestSuite((
         makeSuite(FSZSQLMethodTests),
+        makeSuite(FSZSQLMethodCustomizationTests),
         ))
 
 if __name__ == '__main__':



More information about the CMF-checkins mailing list