Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ResourceRegistries.tests.testJSRegistry.TestZODBTraversal Class Reference
Inheritance diagram for ResourceRegistries.tests.testJSRegistry.TestZODBTraversal:
Inheritance graph
[legend]
Collaboration diagram for ResourceRegistries.tests.testJSRegistry.TestZODBTraversal:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testGetItemTraversal
def testGetItemTraversalContent
def testRestrictedTraverseContent
def testRestrictedTraverseComposition
def testContextDependantInlineJS

Public Attributes

 tool

Detailed Description

Definition at line 554 of file testJSRegistry.py.


Member Function Documentation

Definition at line 556 of file testJSRegistry.py.

00556 
00557     def afterSetUp(self):
00558         self.tool = getattr(self.portal, JSTOOLNAME)
00559         self.tool.clearResources()
00560         self.setRoles(['Manager'])
00561         self.portal.invokeFactory('File',
00562                                    id='testroot.js',
00563                                    format='application/x-javascript',
00564                                    content_type='application/x-javascript',
00565                                    file="window.alert('red')")
00566         self.portal.invokeFactory('Folder', 'subfolder')
00567         self.portal.subfolder.invokeFactory('File',
00568                                    id='testsubfolder.js',
00569                                    format='application/x-javascript',
00570                                    content_type='application/x-javascript',
00571                                    file="window.alert('blue')")
00572 
00573         self.tool.registerScript('testroot.js')
00574         self.tool.registerScript('subfolder/testsubfolder.js')
00575         self.setRoles(['Member'])

Definition at line 605 of file testJSRegistry.py.

00605 
00606     def testContextDependantInlineJS(self):
00607         self.tool.clearResources()
00608         self.setRoles(['Manager'])
00609         self.portal.invokeFactory('Folder', 'folder1')
00610         self.portal.invokeFactory('Folder', 'folder2')
00611         self.portal.folder1.invokeFactory('File',
00612                                    id='context.js',
00613                                    format='application/x-javascript',
00614                                    content_type='application/x-javascript',
00615                                    file="window.alert('pink')")
00616         self.portal.folder2.invokeFactory('File',
00617                                    id='context.js',
00618                                    format='application/x-javascript',
00619                                    content_type='application/x-javascript',
00620                                    file="window.alert('purple')")
00621         self.tool.registerScript('context.js', inline=True)
00622         self.setRoles(['Member'])
00623         view = self.portal.restrictedTraverse('@@plone')
00624         viewletmanager = getMultiAdapter((self.portal.folder1, self.portal.folder1.REQUEST, view), IContentProvider, name = u'plone.resourceregistries.scripts')
00625         viewletmanager.update()
00626         content = viewletmanager.render()
00627         self.failUnless('pink' in content)
00628         self.failIf('purple' in content)
00629         view = self.portal.restrictedTraverse('@@plone')
00630         viewletmanager = getMultiAdapter((self.portal.folder2, self.portal.folder2.REQUEST, view), IContentProvider, name = u'plone.resourceregistries.scripts')
00631         viewletmanager.update()
00632         content = viewletmanager.render()
00633         self.failUnless('purple' in content)
00634         self.failIf('pink' in content)

Here is the call graph for this function:

Definition at line 576 of file testJSRegistry.py.

00576 
00577     def testGetItemTraversal(self):
00578         self.failUnless(self.tool['testroot.js'])
00579         self.failUnless(self.tool['subfolder/testsubfolder.js'])

Definition at line 580 of file testJSRegistry.py.

00580 
00581     def testGetItemTraversalContent(self):
00582         self.failUnless('red' in str(self.tool['testroot.js']))
00583         self.failUnless('blue' in str(self.tool['subfolder/testsubfolder.js']))
00584         self.failIf('blue' in str(self.tool['testroot.js']))
00585         self.failIf('red' in str(self.tool['subfolder/testsubfolder.js']))
00586 

Definition at line 597 of file testJSRegistry.py.

00597 
00598     def testRestrictedTraverseComposition(self):
00599         scripts = self.tool.getEvaluatedResources(self.portal)
00600         self.assertEqual(len(scripts), 1)
00601         magicId = scripts[0].getId()
00602         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicId))
00603         self.failUnless('red' in content)
00604         self.failUnless('blue' in content)

Here is the call graph for this function:

Definition at line 587 of file testJSRegistry.py.

00587 
00588     def testRestrictedTraverseContent(self):
00589         self.failUnless('red' in str(
00590                         self.portal.restrictedTraverse('portal_javascripts/testroot.js')))
00591         self.failUnless('blue' in str(
00592                         self.portal.restrictedTraverse('portal_javascripts/subfolder/testsubfolder.js')))
00593         self.failIf('blue' in str(
00594                         self.portal.restrictedTraverse('portal_javascripts/testroot.js')))
00595         self.failIf('red' in str(
00596                         self.portal.restrictedTraverse('portal_javascripts/subfolder/testsubfolder.js')))


Member Data Documentation

Definition at line 557 of file testJSRegistry.py.


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