[CMF-checkins] CVS: CMF/CMFSetup/tests - test_typeinfo.py:1.2
Tres Seaver
tseaver at zope.com
Sat May 29 19:45:25 EDT 2004
Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv3407/tests
Modified Files:
test_typeinfo.py
Log Message:
- Split out dumped configuration of the tool from each type info, in
preparation for splitting them out into separate files.
=== CMF/CMFSetup/tests/test_typeinfo.py 1.1 => 1.2 ===
--- CMF/CMFSetup/tests/test_typeinfo.py:1.1 Thu May 27 00:23:51 2004
+++ CMF/CMFSetup/tests/test_typeinfo.py Sat May 29 19:44:54 2004
@@ -29,7 +29,12 @@
def getTypeInfo( self, id ):
- info = [ x for x in self._type_infos if x[ 'id' ] == id ][ 0 ]
+ info = [ x for x in self._type_infos if x[ 'id' ] == id ]
+
+ if len( info ) == 0:
+ raise KeyError, id
+
+ info = info[ 0 ]
if 'product' in info.keys():
return FactoryTypeInformation( **info )
@@ -51,6 +56,106 @@
return self.root.site
+ def test_getTypeInfo_nonesuch( self ):
+
+ site = self._initSite( _TI_LIST )
+ configurator = self._makeOne( site ).__of__( site )
+
+ self.assertRaises( ValueError, configurator.getTypeInfo, 'qux' )
+
+ def test_getTypeInfo_FTI( self ):
+
+ site = self._initSite( _TI_LIST )
+ configurator = self._makeOne( site ).__of__( site )
+ found = configurator.getTypeInfo( 'foo' )
+ expected = _TI_LIST[ 0 ]
+
+ for key in ( 'id'
+ , 'title'
+ , 'description'
+ , 'factory'
+ , 'product'
+ , 'factory'
+ , 'immediate_view'
+ , 'filter_content_types'
+ , 'allowed_content_types'
+ , 'allow_discussion'
+ , 'global_allow'
+ , 'aliases'
+ ):
+ self.assertEqual( found[ key ], expected[ key ] )
+
+ for lkey, rkey in ( ( 'meta_type', 'content_meta_type' )
+ , ( 'icon', 'content_icon' )
+ ):
+ self.assertEqual( found[ lkey ], expected[ rkey ] )
+
+ self.assertEqual( len( found[ 'actions' ] )
+ , len( expected[ 'actions' ] )
+ )
+
+ for i in range( len( expected[ 'actions' ] ) ):
+
+ a_expected = expected[ 'actions' ][ i ]
+ a_found = found[ 'actions' ][ i ]
+
+ for k in ( 'id'
+ , 'action'
+ , 'permissions'
+ ):
+ self.assertEqual( a_expected[ k ], a_found[ k ] )
+
+ for lk, rk in ( ( 'name', 'title' )
+ ,
+ ):
+ self.assertEqual( a_expected[ lk ], a_found[ rk ] )
+
+ def test_getTypeInfo_STI( self ):
+
+ site = self._initSite( _TI_LIST )
+ configurator = self._makeOne( site ).__of__( site )
+ found = configurator.getTypeInfo( 'bar' )
+ expected = _TI_LIST[ 1 ]
+
+ for key in ( 'id'
+ , 'title'
+ , 'description'
+ , 'constructor_path'
+ , 'permission'
+ , 'immediate_view'
+ , 'filter_content_types'
+ , 'allowed_content_types'
+ , 'allow_discussion'
+ , 'global_allow'
+ , 'aliases'
+ ):
+ self.assertEqual( found[ key ], expected[ key ] )
+
+ for lkey, rkey in ( ( 'meta_type', 'content_meta_type' )
+ , ( 'icon', 'content_icon' )
+ ):
+ self.assertEqual( found[ lkey ], expected[ rkey ] )
+
+ self.assertEqual( len( found[ 'actions' ] )
+ , len( expected[ 'actions' ] )
+ )
+
+ for i in range( len( expected[ 'actions' ] ) ):
+
+ a_expected = expected[ 'actions' ][ i ]
+ a_found = found[ 'actions' ][ i ]
+
+ for k in ( 'id'
+ , 'action'
+ , 'permissions'
+ ):
+ self.assertEqual( a_expected[ k ], a_found[ k ] )
+
+ for lk, rk in ( ( 'name', 'title' )
+ ,
+ ):
+ self.assertEqual( a_expected[ lk ], a_found[ rk ] )
+
def test_listTypeInfo_empty( self ):
site = self._initSite()
@@ -58,7 +163,6 @@
self.assertEqual( len( configurator.listTypeInfo() ), 0 )
-
def test_listTypeInfo_filled ( self ):
site = self._initSite( _TI_LIST )
@@ -77,19 +181,28 @@
# type information object in a separate file, all grouped in a
# 'typeinfo' subdirectory within the export.
#
- def test_generateXML_empty( self ):
+ def test_generateToolXML_empty( self ):
site = self._initSite()
configurator = self._makeOne( site ).__of__( site )
+ self._compareDOM( configurator.generateToolXML(), _EMPTY_EXPORT )
- self._compareDOM( configurator.generateXML(), _EMPTY_EXPORT )
+ def test_generateToolXML_normal( self ):
- def test_generateXML_normal( self ):
+ site = self._initSite( _TI_LIST )
+ configurator = self._makeOne( site ).__of__( site )
+
+ def test_generateTypeXML_FTI( self ):
site = self._initSite( _TI_LIST )
configurator = self._makeOne( site ).__of__( site )
+ self._compareDOM( configurator.generateTypeXML( 'foo' ), _FOO_EXPORT )
- self._compareDOM( configurator.generateXML(), _NORMAL_EXPORT )
+ def test_generateTypeXML_STI( self ):
+
+ site = self._initSite( _TI_LIST )
+ configurator = self._makeOne( site ).__of__( site )
+ self._compareDOM( configurator.generateTypeXML( 'bar' ), _BAR_EXPORT )
@@ -175,108 +288,116 @@
_NORMAL_EXPORT = """\
<?xml version="1.0"?>
<types-tool>
- <type-info
- id="foo"
- kind="Factory-based Type Information"
- title="Foo"
- meta_type="Foo Thing"
- icon="foo.png"
- product="CMFSetup"
- factory="addFoo"
- immediate_view="foo_view"
- filter_content_types="False"
- allowed_content_types=""
- allow_discussion="False"
- global_allow="False" >
- <description>Foo things</description>
- <aliases>
- <alias from="(Default)" to="foo_view" />
- <alias from="view" to="foo_view" />
- </aliases>
- <action
- action_id="view"
- title="View"
- action_expr="string:${object_url}/foo_view"
- condition=""
- permissions="View"
- category="object"
- visible="True"
- />
- <action
- action_id="edit"
- title="Edit"
- action_expr="string:${object_url}/foo_edit_form"
- condition=""
- permissions="Modify portal content"
- category="object"
- visible="True"
- />
- <action
- action_id="metadata"
- title="Metadata"
- action_expr="string:${object_url}/metadata_edit_form"
- condition=""
- permissions="Modify portal content"
- category="object"
- visible="True"
- />
- </type-info>
- <type-info
- id="bar"
- kind="Scriptable Type Information"
- title="Bar"
- meta_type="Bar Thing"
- icon="bar.png"
- constructor_path="make_bar"
- permission="Add portal content"
- immediate_view="bar_view"
- filter_content_types="True"
- allowed_content_types="foo"
- allow_discussion="True"
- global_allow="True" >
- <description>Bar things</description>
- <aliases>
- <alias from="(Default)" to="bar_view" />
- <alias from="view" to="bar_view" />
- </aliases>
- <action
- action_id="view"
- title="View"
- action_expr="string:${object_url}/bar_view"
- condition=""
- permissions="View"
- category="object"
- visible="True"
- />
- <action
- action_id="edit"
- title="Edit"
- action_expr="string:${object_url}/bar_edit_form"
- condition=""
- permissions="Modify portal content"
- category="object"
- visible="True"
- />
- <action
- action_id="contents"
- title="Contents"
- action_expr="string:${object_url}/folder_contents"
- condition=""
- permissions="Access contents information"
- category="object"
- visible="True"
- />
- <action
- action_id="metadata"
- title="Metadata"
- action_expr="string:${object_url}/metadata_edit_form"
- condition=""
- permissions="Modify portal content"
- category="object"
- visible="True"
- />
- </type-info>
+ <type>foo</type>
+ <type>bar</type>
</types-tool>
+"""
+
+_FOO_EXPORT = """\
+<type-info
+ id="foo"
+ kind="Factory-based Type Information"
+ title="Foo"
+ meta_type="Foo Thing"
+ icon="foo.png"
+ product="CMFSetup"
+ factory="addFoo"
+ immediate_view="foo_view"
+ filter_content_types="False"
+ allowed_content_types=""
+ allow_discussion="False"
+ global_allow="False" >
+ <description>Foo things</description>
+ <aliases>
+ <alias from="(Default)" to="foo_view" />
+ <alias from="view" to="foo_view" />
+ </aliases>
+ <action
+ action_id="view"
+ title="View"
+ action_expr="string:${object_url}/foo_view"
+ condition=""
+ permissions="View"
+ category="object"
+ visible="True"
+ />
+ <action
+ action_id="edit"
+ title="Edit"
+ action_expr="string:${object_url}/foo_edit_form"
+ condition=""
+ permissions="Modify portal content"
+ category="object"
+ visible="True"
+ />
+ <action
+ action_id="metadata"
+ title="Metadata"
+ action_expr="string:${object_url}/metadata_edit_form"
+ condition=""
+ permissions="Modify portal content"
+ category="object"
+ visible="True"
+ />
+</type-info>
+"""
+
+_BAR_EXPORT = """\
+<type-info
+ id="bar"
+ kind="Scriptable Type Information"
+ title="Bar"
+ meta_type="Bar Thing"
+ icon="bar.png"
+ constructor_path="make_bar"
+ permission="Add portal content"
+ immediate_view="bar_view"
+ filter_content_types="True"
+ allowed_content_types="foo"
+ allow_discussion="True"
+ global_allow="True" >
+ <description>Bar things</description>
+ <aliases>
+ <alias from="(Default)" to="bar_view" />
+ <alias from="view" to="bar_view" />
+ </aliases>
+ <action
+ action_id="view"
+ title="View"
+ action_expr="string:${object_url}/bar_view"
+ condition=""
+ permissions="View"
+ category="object"
+ visible="True"
+ />
+ <action
+ action_id="edit"
+ title="Edit"
+ action_expr="string:${object_url}/bar_edit_form"
+ condition=""
+ permissions="Modify portal content"
+ category="object"
+ visible="True"
+ />
+ <action
+ action_id="contents"
+ title="Contents"
+ action_expr="string:${object_url}/folder_contents"
+ condition=""
+ permissions="Access contents information"
+ category="object"
+ visible="True"
+ />
+ <action
+ action_id="metadata"
+ title="Metadata"
+ action_expr="string:${object_url}/metadata_edit_form"
+ condition=""
+ permissions="Modify portal content"
+ category="object"
+ visible="True"
+ />
+</type-info>
"""
More information about the CMF-checkins
mailing list