Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testDefaultStylesheetCookableAttribute
def testStylesheetCookableAttribute
def testNumberOfResources
def testCompositionWithLastUncooked
def testCompositionWithFirstUncooked
def testCompositionWithMiddleUncooked
def testLargerCompositionWithMiddleUncooked

Public Attributes

 tool

Detailed Description

Definition at line 731 of file testJSRegistry.py.


Member Function Documentation

Definition at line 733 of file testJSRegistry.py.

00733 
00734     def afterSetUp(self):
00735         self.tool = getattr(self.portal, JSTOOLNAME)
00736         self.tool.clearResources()
00737         self.tool.registerScript('testroot.js')
00738         self.tool.registerScript('test_rr_1.js')
00739         self.tool.registerScript('simple2.js', cookable=False)
00740         self.setRoles(['Manager'])
00741         self.portal.invokeFactory('File',
00742                                    id='testroot.js',
00743                                    format='application/x-javascript',
00744                                    content_type='application/x-javascript',
00745                                    file="window.alert('green')")
00746         self.portal.invokeFactory('File',
00747                                    id='simple2.js',
00748                                    format='application/x-javascript',
00749                                    content_type='application/x-javascript',
00750                                    file="window.alert('blue')")
00751         self.setRoles(['Member'])

Definition at line 790 of file testJSRegistry.py.

00790 
00791     def testCompositionWithFirstUncooked(self):
00792         self.tool.moveResourceToTop('simple2.js')
00793         self.assertEqual(len(self.tool.getResources()), 3)
00794         self.assertEqual(len(self.tool.cookedresources), 2)
00795         self.assertEqual(len(self.tool.concatenatedresources), 5)
00796         scripts = self.tool.getEvaluatedResources(self.portal)
00797         self.assertEqual(len(scripts), 2)
00798         magicId = None
00799         for script in scripts:
00800             id = script.getId()
00801             if '-cachekey' in id:
00802                 magicId = id
00803         self.failUnless(magicId)
00804         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicId))
00805         self.failUnless('running' in content)
00806         self.failUnless('green' in content)
00807         self.failIf('blue' in content)
00808         content = str(self.portal.restrictedTraverse('portal_javascripts/simple2.js'))
00809         self.failUnless('blue' in content)

Here is the call graph for this function:

Definition at line 766 of file testJSRegistry.py.

00766 
00767     def testCompositionWithLastUncooked(self):
00768         self.tool.moveResourceToBottom('simple2.js')
00769         self.assertEqual(len(self.tool.getResources()), 3)
00770         self.assertEqual(len(self.tool.cookedresources), 2)
00771         self.assertEqual(len(self.tool.concatenatedresources), 5)
00772         scripts = self.tool.getEvaluatedResources(self.portal)
00773         self.assertEqual(len(scripts), 2)
00774         magicIds = []
00775         for script in scripts:
00776             id = script.getId()
00777             if '-cachekey' in id:
00778                 magicIds.append(id)
00779         self.failUnless(magicIds[-1].startswith('simple2'))
00780         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicIds[-2]))
00781         self.failUnless('running' in content)
00782         self.failUnless('green' in content)
00783         self.failIf('blue' in content)
00784         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicIds[-1]))
00785         self.failIf('running' in content)
00786         self.failIf('green' in content)
00787         self.failUnless('blue' in content)
00788         content = str(self.portal.restrictedTraverse('portal_javascripts/simple2.js'))
00789         self.failUnless('blue' in content)

Here is the call graph for this function:

Definition at line 810 of file testJSRegistry.py.

00810 
00811     def testCompositionWithMiddleUncooked(self):
00812         self.tool.moveResourceToTop('simple2.js')
00813         self.tool.moveResourceDown('simple2.js')
00814         self.assertEqual(len(self.tool.getResources()), 3)
00815         self.assertEqual(len(self.tool.cookedresources), 3)
00816         self.assertEqual(len(self.tool.concatenatedresources), 6)
00817         scripts = self.tool.getEvaluatedResources(self.portal)
00818         self.assertEqual(len(scripts), 3)
00819         content = str(self.portal.restrictedTraverse('portal_javascripts/simple2.js'))
00820         self.failUnless('blue' in content)
00821         content = str(self.portal.restrictedTraverse('portal_javascripts/test_rr_1.js'))
00822         self.failUnless('running' in content)
00823         content = str(self.portal.restrictedTraverse('portal_javascripts/testroot.js'))
00824         self.failUnless('green' in content)

Here is the call graph for this function:

Definition at line 752 of file testJSRegistry.py.

00752 
00753     def testDefaultStylesheetCookableAttribute(self):
00754         self.failUnless(self.tool.getResources()[self.tool.getResourcePosition('test_rr_1.js')].getCookable())
00755         self.failUnless(self.tool.getResources()[self.tool.getResourcePosition('testroot.js')].getCookable())

Definition at line 825 of file testJSRegistry.py.

00825 
00826     def testLargerCompositionWithMiddleUncooked(self):
00827         self.setRoles(['Manager'])
00828         self.portal.invokeFactory('File',
00829                                    id='testpurple.js',
00830                                    format='application/x-javascript',
00831                                    content_type='application/x-javascript',
00832                                    file="window.alert('purple')")
00833         self.portal.invokeFactory('File',
00834                                    id='testpink.js',
00835                                    format='application/x-javascript',
00836                                    content_type='application/x-javascript',
00837                                    file="window.alert('pink')")
00838         self.setRoles(['Member'])
00839         self.tool.registerScript('testpurple.js')
00840         self.tool.registerScript('testpink.js')
00841         self.tool.moveResourceToTop('simple2.js')
00842         self.tool.moveResourceDown('simple2.js', 2)
00843         #Now have [[green,running],blue,[purple,pink]]
00844         self.assertEqual(len(self.tool.getResources()), 5)
00845         self.assertEqual(len(self.tool.cookedresources), 3)
00846         self.assertEqual(len(self.tool.concatenatedresources), 8)
00847         scripts = self.tool.getEvaluatedResources(self.portal)
00848         self.assertEqual(len(scripts), 3)
00849         magicIds = []
00850         for script in scripts:
00851             id = script.getId()
00852             if '-cachekey' in id:
00853                 magicIds.append(id)
00854         self.assertEqual(len(magicIds), 3)
00855         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicIds[0]))
00856         self.failUnless('running' in content)
00857         self.failUnless('green' in content)
00858         self.failIf('pink' in content)
00859         self.failIf('purple' in content)
00860         content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicIds[2]))
00861         self.failUnless('pink' in content)
00862         self.failUnless('purple' in content)
00863         self.failIf('running' in content)
00864         self.failIf('green' in content)
00865         content = str(self.portal.restrictedTraverse('portal_javascripts/simple2.js'))
00866         self.failUnless('blue' in content)
00867 

Here is the call graph for this function:

Definition at line 759 of file testJSRegistry.py.

00759 
00760     def testNumberOfResources(self):
00761         self.assertEqual(len(self.tool.getResources()), 3)
00762         self.assertEqual(len(self.tool.cookedresources), 2)
00763         self.assertEqual(len(self.tool.concatenatedresources), 5)
00764         scripts = self.tool.getEvaluatedResources(self.portal)
00765         self.assertEqual(len(scripts), 2)

Here is the call graph for this function:

Definition at line 756 of file testJSRegistry.py.

00756 
00757     def testStylesheetCookableAttribute(self):
00758         self.failIf(self.tool.getResources()[self.tool.getResourcePosition('simple2.js')].getCookable())


Member Data Documentation

Definition at line 734 of file testJSRegistry.py.


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