Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
CMFCore.tests.test_TypesTool.TypesToolTests Class Reference
Inheritance diagram for CMFCore.tests.test_TypesTool.TypesToolTests:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.tests.test_TypesTool.TypesToolTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_z2interfaces
def test_z3interfaces
def test_listActions
def test_allMetaTypes
def test_constructContent

Public Attributes

 site
 acl_users
 ttool

Static Public Attributes

 layer = FunctionalZCMLLayer

Private Member Functions

def _makeOne

Detailed Description

Definition at line 65 of file test_TypesTool.py.


Member Function Documentation

Definition at line 69 of file test_TypesTool.py.

00069 
00070     def _makeOne(self):
00071         from Products.CMFCore.TypesTool import TypesTool
00072 
00073         return TypesTool()

Definition at line 74 of file test_TypesTool.py.

00074 
00075     def setUp(self):
00076         from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
00077 
00078         SecurityTest.setUp(self)
00079         self.site = DummySite('site').__of__(self.root)
00080         self.acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
00081         self.ttool = self.site._setObject( 'portal_types', self._makeOne() )
00082         fti = FTIDATA_DUMMY[0].copy()
00083         self.ttool._setObject( 'Dummy Content', FTI(**fti) )

Definition at line 84 of file test_TypesTool.py.

00084 
00085     def tearDown(self):
00086         SecurityTest.tearDown(self)
00087         self._free_warning_output()

Here is the call graph for this function:

Test that everything returned by allMetaTypes can be
traversed to.

Definition at line 122 of file test_TypesTool.py.

00122 
00123     def test_allMetaTypes(self):
00124         """
00125         Test that everything returned by allMetaTypes can be
00126         traversed to.
00127         """
00128         tool = self.ttool
00129         meta_types={}
00130         # Seems we get NullResource if the method couldn't be traverse to
00131         # so we check for that. If we've got it, something is b0rked.
00132         for factype in tool.all_meta_types():
00133             meta_types[factype['name']]=1
00134             # The html_quote below is necessary 'cos of the one in
00135             # main.dtml. Could be removed once that is gone.
00136             act = tool.unrestrictedTraverse(html_quote(factype['action']))
00137             self.failIf(type(aq_base(act)) is NullResource)
00138 
00139         # Check the ones we're expecting are there
00140         self.failUnless(meta_types.has_key('Scriptable Type Information'))
00141         self.failUnless(meta_types.has_key('Factory-based Type Information'))

Definition at line 142 of file test_TypesTool.py.

00142 
00143     def test_constructContent(self):
00144         from Products.CMFCore.TypesTool \
00145                 import ScriptableTypeInformation as STI
00146 
00147         site = self.site
00148         acl_users = self.acl_users
00149         ttool = self.ttool
00150         setSecurityPolicy(self._oldPolicy)
00151         newSecurityManager(None, acl_users.all_powerful_Oz)
00152         self.site._owner = (['acl_users'], 'all_powerful_Oz')
00153         sti_baz = STI('Baz',
00154                       permission='Add portal content',
00155                       constructor_path='addBaz')
00156         ttool._setObject('Baz', sti_baz)
00157         ttool._setObject( 'addBaz',  PythonScript('addBaz') )
00158         s = ttool.addBaz
00159         s.write(STI_SCRIPT)
00160 
00161         f = site._setObject( 'folder', PortalFolder(id='folder') )
00162         f.manage_addProduct = { 'FooProduct' : DummyFactoryDispatcher(f) }
00163         f._owner = (['acl_users'], 'user_foo')
00164         self.assertEqual( f.getOwner(), acl_users.user_foo )
00165 
00166         ttool.constructContent('Dummy Content', container=f, id='page1')
00167         try:
00168             ttool.constructContent('Baz', container=f, id='page2')
00169         except Unauthorized:
00170             self.fail('CMF Collector issue #165 (Ownership bug): '
00171                       'Unauthorized raised' )
00172 

Here is the call graph for this function:

test that a full set of context information is passed
   by the types tool

Definition at line 108 of file test_TypesTool.py.

00108 
00109     def test_listActions(self):
00110         """test that a full set of context information is passed
00111            by the types tool
00112         """
00113         tool = self.ttool
00114         ti = ActionTesterTypeInfo()
00115         setattr( tool, 'Dummy Content', ti )
00116 
00117         dummy = self.site._setObject('dummy', DummyContent('dummy'))
00118         tool.listActions('fake_info', dummy)
00119 
00120         self.assertEqual(ti._action_info, 'fake_info')
00121         self.assertEqual(ti._action_obj, dummy)

Definition at line 88 of file test_TypesTool.py.

00088 
00089     def test_z2interfaces(self):
00090         from Interface.Verify import verifyClass
00091         from Products.CMFCore.interfaces.portal_actions \
00092                 import ActionProvider as IActionProvider
00093         from Products.CMFCore.interfaces.portal_types \
00094                 import portal_types as ITypesTool
00095         from Products.CMFCore.TypesTool import TypesTool
00096 
00097         verifyClass(IActionProvider, TypesTool)
00098         verifyClass(ITypesTool, TypesTool)

Definition at line 99 of file test_TypesTool.py.

00099 
00100     def test_z3interfaces(self):
00101         from zope.interface.verify import verifyClass
00102         from Products.CMFCore.interfaces import IActionProvider
00103         from Products.CMFCore.interfaces import ITypesTool
00104         from Products.CMFCore.TypesTool import TypesTool
00105 
00106         verifyClass(IActionProvider, TypesTool)
00107         verifyClass(ITypesTool, TypesTool)


Member Data Documentation

Definition at line 79 of file test_TypesTool.py.

CMFCore.tests.test_TypesTool.TypesToolTests.layer = FunctionalZCMLLayer [static]

Definition at line 67 of file test_TypesTool.py.

Definition at line 78 of file test_TypesTool.py.

Definition at line 80 of file test_TypesTool.py.


The documentation for this class was generated from the following file: