[CMF-checkins] CVS: CMF/CMFSetup/tests - test_actions.py:1.12 test_skins.py:1.15

Yvo Schubbe y.2005- at wcm-solutions.de
Mon Apr 11 07:33:17 EDT 2005


Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv2828/CMFSetup/tests

Modified Files:
	test_actions.py test_skins.py 
Log Message:
improved update behavior of extension profiles (see PROFILES.txt for details)


=== CMF/CMFSetup/tests/test_actions.py 1.11 => 1.12 ===
--- CMF/CMFSetup/tests/test_actions.py:1.11	Tue Jan 25 14:49:42 2005
+++ CMF/CMFSetup/tests/test_actions.py	Mon Apr 11 07:33:17 2005
@@ -265,6 +265,57 @@
 </actions-tool>
 """
 
+_NEWSYTLE_EXPORT = """\
+<?xml version="1.0"?>
+<actions-tool>
+ <action-provider id="portal_actions">
+ </action-provider>
+ <object name="dummy" meta_type="CMF Action Category">
+  <property name="title"></property>
+ <object name="foo" meta_type="CMF Action">
+  <property name="title">Foo</property>
+  <property name="description"></property>
+  <property name="url_expr">string:${object_url}/foo</property>
+  <property name="icon_expr"></property>
+  <property name="available_expr">python:1</property>
+  <property name="permissions"></property>
+  <property name="visible">True</property>
+ </object>
+ <object name="bar" meta_type="CMF Action">
+  <property name="title">Bar</property>
+  <property name="description"></property>
+  <property name="url_expr">string:${object_url}/bar</property>
+  <property name="icon_expr"></property>
+  <property name="available_expr">python:0</property>
+  <property name="permissions">
+   <element value="Manage portal" /></property>
+  <property name="visible">False</property>
+ </object>
+ </object>
+</actions-tool>
+"""
+
+_FRAGMENT_IMPORT = """\
+<?xml version="1.0"?>
+<actions-tool>
+ <object name="dummy">
+ <object name="spam" meta_type="CMF Action" insert-before="*">
+  <property name="title">Spam</property>
+  <property name="description"></property>
+  <property name="url_expr">string:${object_url}/spam</property>
+  <property name="icon_expr">string:spam_icon.png</property>
+  <property name="available_expr"></property>
+  <property name="permissions">
+   <element value="View" /></property>
+  <property name="visible">True</property>
+ </object>
+ <object name="foo" insert-after="*">
+  <property name="icon_expr">string:foo_icon.png</property>
+ </object>
+ </object>
+</actions-tool>
+"""
+
 
 class Test_exportActionProviders( _ActionSetup ):
 
@@ -391,6 +442,17 @@
         self.failIf( foo.listActions() )
         self.failIf( bar.listActions() )
 
+        # complete the roundtrip
+        context = DummyExportContext( site )
+        from Products.CMFSetup.actions import exportActionProviders
+        exportActionProviders( context )
+
+        self.assertEqual( len( context._wrote ), 1 )
+        filename, text, content_type = context._wrote[ 0 ]
+        self.assertEqual( filename, 'actions.xml' )
+        self._compareDOM( text, _NEWSYTLE_EXPORT )
+        self.assertEqual( content_type, 'text/xml' )
+
     def test_normal_encode_as_ascii( self ):
 
         site = self._initSite( 1, 1 )
@@ -415,6 +477,31 @@
         self.failUnless( 'bar' in atool.dummy.objectIds() )
         self.failIf( foo.listActions() )
         self.failIf( bar.listActions() )
+
+    def test_fragment_skip_purge(self):
+
+        from Products.CMFSetup.actions import importActionProviders
+
+        site = self._initSite(0, 0)
+        atool = site.portal_actions
+
+        context = DummyImportContext(site)
+        context._files['actions.xml'] = _NEWSYTLE_EXPORT
+        importActionProviders(context)
+
+        self.assertEqual( len( atool.listActionProviders() ), 1 )
+        self.assertEqual( atool.objectIds(), ['dummy'] )
+        self.assertEqual( atool.dummy.objectIds(), ['foo', 'bar'] )
+        self.assertEqual( atool.dummy.foo.icon_expr, '' )
+
+        context = DummyImportContext(site, False)
+        context._files['actions.xml'] = _FRAGMENT_IMPORT
+        importActionProviders(context)
+
+        self.assertEqual( len( atool.listActionProviders() ), 1 )
+        self.assertEqual( atool.objectIds(), ['dummy'] )
+        self.assertEqual( atool.dummy.objectIds(), ['spam', 'bar', 'foo'] )
+        self.assertEqual( atool.dummy.foo.icon_expr, 'string:foo_icon.png' )
 
 
 def test_suite():


=== CMF/CMFSetup/tests/test_skins.py 1.14 => 1.15 ===
--- CMF/CMFSetup/tests/test_skins.py:1.14	Sun Mar 27 12:57:20 2005
+++ CMF/CMFSetup/tests/test_skins.py	Mon Apr 11 07:33:17 2005
@@ -281,7 +281,7 @@
 </skins-tool>
 """
 
-_FRAGMENT_IMPORT2 = """\
+_FRAGMENT2_IMPORT = """\
 <?xml version="1.0"?>
 <skins-tool>
  <skin-directory id="four" directory="CMFSetup/tests/four" />
@@ -291,6 +291,17 @@
 </skins-tool>
 """
 
+_FRAGMENT3_IMPORT = """\
+<?xml version="1.0"?>
+<skins-tool>
+ <skin-directory id="three" directory="CMFSetup/tests/three" />
+ <skin-directory id="four" directory="CMFSetup/tests/four" />
+ <skin-path id="*">
+  <layer name="three" insert-before="*"/>
+  <layer name="four" insert-after="*"/>
+ </skin-path>
+</skins-tool>
+"""
 
 class Test_exportSkinsTool( _SkinsSetup ):
 
@@ -516,7 +527,7 @@
         self.assertEqual( len( skins_tool.objectItems() ), 3 )
 
         self._registerDirectoryView( os.path.join( _TESTS_PATH, 'four' ) )
-        context._files[ 'skins.xml' ] = _FRAGMENT_IMPORT2
+        context._files[ 'skins.xml' ] = _FRAGMENT2_IMPORT
         importSkinsTool( context )
 
         self.assertEqual( skins_tool.default_skin, "default_skin" )
@@ -530,6 +541,44 @@
         self.assertEqual( skin_paths[ 0 ], ( 'basic', 'one,three,four' ) )
         self.assertEqual( skin_paths[ 1 ], ( 'fancy', 'three,four,two,one' ) )
         self.assertEqual( len( skins_tool.objectItems() ), 4 )
+
+    def test_fragment3_skip_purge(self):
+
+        _IDS = ( 'one', 'two' )
+        _FSDVS = [ ( id, DummyFSDV( id ) ) for id in _IDS ]
+        _PATHS = { 'basic' : 'one', 'fancy' : 'two,one' }
+
+        site = self._initSite( selections=_PATHS, fsdvs=_FSDVS )
+        self._registerDirectoryView( os.path.join( _TESTS_PATH, 'three' ) )
+        self._registerDirectoryView( os.path.join( _TESTS_PATH, 'four' ) )
+        skins_tool = site.portal_skins
+
+        self.failIf( site._skin_setup_called )
+        skin_paths = skins_tool.getSkinPaths()
+        self.assertEqual( len( skin_paths ), 2 )
+        self.assertEqual( skin_paths[ 0 ], ( 'basic', 'one' ) )
+        self.assertEqual( skin_paths[ 1 ], ( 'fancy', 'two,one' ) )
+        self.assertEqual( len( skins_tool.objectItems() ), 2 )
+
+        context = DummyImportContext( site, False )
+        context._files[ 'skins.xml' ] = _FRAGMENT3_IMPORT
+
+        from Products.CMFSetup.skins import importSkinsTool
+        importSkinsTool( context )
+
+        self.assertEqual( skins_tool.default_skin, "default_skin" )
+        self.assertEqual( skins_tool.request_varname, "request_varname" )
+        self.failIf( skins_tool.allow_any )
+        self.failIf( skins_tool.cookie_persistence )
+
+        self.failUnless( site._skin_setup_called )
+        skin_paths = skins_tool.getSkinPaths()
+        self.assertEqual( len( skin_paths ), 2 )
+        self.assertEqual( skin_paths[ 0 ], ( 'basic', 'three,one,four' ) )
+        self.assertEqual( skin_paths[ 1 ],
+                          ( 'fancy', 'three,two,one,four' ) )
+        self.assertEqual( len( skins_tool.objectItems() ), 4 )
+
 
 def test_suite():
     return unittest.TestSuite((



More information about the CMF-checkins mailing list