Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testScriptCooking
def testScriptCookingValues
def testGetEvaluatedScriptsCollapsing
def testMoreComplexScriptsCollapsing
def testGetEvaluatedScriptsWithExpression
def testGetEvaluatedScriptsWithFailingExpression
def testGetEvaluatedScriptsWithContextualExpression
def testCollapsingScriptsLookup
def testRenderingIsInTheRightOrder
def testRenderingScriptLinks
def testReenderingConcatenatesInline
def testRenderingWorksInMainTemplate

Public Attributes

 tool

Detailed Description

Definition at line 166 of file testJSRegistry.py.


Member Function Documentation

Definition at line 168 of file testJSRegistry.py.

00168 
00169     def afterSetUp(self):
00170         self.tool = getattr(self.portal, JSTOOLNAME)
00171         self.tool.clearResources()

Definition at line 242 of file testJSRegistry.py.

00242 
00243     def testCollapsingScriptsLookup(self):
00244         self.tool.registerScript('ham')
00245         self.tool.registerScript('spam', expression='string:spam')
00246         self.tool.registerScript('spam spam', expression='string:spam')
00247         evaluated = self.tool.getEvaluatedResources(self.folder)
00248         self.assertEqual(len(evaluated), 2)
00249         self.tool.setAutoGroupingMode(True)
00250         evaluated = self.tool.getEvaluatedResources(self.folder)
00251         self.assertEqual(len(evaluated), 2)

Here is the call graph for this function:

Definition at line 192 of file testJSRegistry.py.

00192 
00193     def testGetEvaluatedScriptsCollapsing(self):
00194         self.tool.registerScript('ham')
00195         self.tool.registerScript('spam')
00196         self.tool.registerScript('eggs')
00197         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 1)

Here is the call graph for this function:

Definition at line 235 of file testJSRegistry.py.

00235 
00236     def testGetEvaluatedScriptsWithContextualExpression(self):
00237         self.folder.invokeFactory('Document', 'eggs')
00238         self.tool.registerScript('spam', expression='python:"eggs" in object.objectIds()')
00239         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 1)
00240         self.tool.setAutoGroupingMode(True)
00241         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 1)

Here is the call graph for this function:

Definition at line 221 of file testJSRegistry.py.

00221 
00222     def testGetEvaluatedScriptsWithExpression(self):
00223         self.tool.registerScript('ham')
00224         self.tool.registerScript('spam', expression='python:1')
00225         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 2)
00226         self.tool.setAutoGroupingMode(True)
00227         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 2)

Here is the call graph for this function:

Definition at line 228 of file testJSRegistry.py.

00228 
00229     def testGetEvaluatedScriptsWithFailingExpression(self):
00230         self.tool.registerScript('ham')
00231         self.tool.registerScript('spam', expression='python:0')
00232         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 1)
00233         self.tool.setAutoGroupingMode(True)
00234         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 1)

Here is the call graph for this function:

Definition at line 198 of file testJSRegistry.py.

00198 
00199     def testMoreComplexScriptsCollapsing(self):
00200         self.tool.registerScript('ham')
00201         self.tool.registerScript('spam', expression='string:spam')
00202         self.tool.registerScript('spam spam', expression='string:spam')
00203         self.tool.registerScript('spam spam spam', expression='string:spam')
00204         self.tool.registerScript('eggs')
00205         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 3)
00206         magic_ids = [item.getId() for item in self.tool.getEvaluatedResources(self.folder)]
00207         self.failUnless('ham' in self.tool.concatenatedresources[magic_ids[0]])
00208         self.failUnless('eggs' in self.tool.concatenatedresources[magic_ids[2]])
00209         self.failUnless('spam' in self.tool.concatenatedresources[magic_ids[1]])
00210         self.failUnless('spam spam' in self.tool.concatenatedresources[magic_ids[1]])
00211         self.failUnless('spam spam spam' in self.tool.concatenatedresources[magic_ids[1]])
00212 
00213         self.tool.setAutoGroupingMode(True)
00214         self.assertEqual(len(self.tool.getEvaluatedResources(self.folder)), 2)
00215         magic_ids = [item.getId() for item in self.tool.getEvaluatedResources(self.folder)]
00216         self.failUnless('ham' in self.tool.concatenatedresources[magic_ids[0]])
00217         self.failUnless('eggs' in self.tool.concatenatedresources[magic_ids[0]])
00218         self.failUnless('spam' in self.tool.concatenatedresources[magic_ids[1]])
00219         self.failUnless('spam spam' in self.tool.concatenatedresources[magic_ids[1]])
00220         self.failUnless('spam spam spam' in self.tool.concatenatedresources[magic_ids[1]])

Here is the call graph for this function:

Definition at line 279 of file testJSRegistry.py.

00279 
00280     def testReenderingConcatenatesInline(self):
00281         self.tool.registerScript('test_rr_1.css', inline='1')
00282         self.tool.registerScript('test_rr_2.css', inline='1')
00283         view = self.portal.restrictedTraverse('@@plone')
00284         viewletmanager = getMultiAdapter((self.portal, self.portal.REQUEST, view), IContentProvider, name = u'plone.resourceregistries.scripts')
00285         viewletmanager.update()
00286         all = viewletmanager.render()
00287         self.failUnless('background-color' in all)
00288         self.failUnless('blue' in all)

Here is the call graph for this function:

Definition at line 252 of file testJSRegistry.py.

00252 
00253     def testRenderingIsInTheRightOrder(self):
00254         self.tool.registerScript('ham', expression='string:ham')
00255         self.tool.registerScript('spam', expression='string:spam')
00256         evaluated = self.tool.getEvaluatedResources(self.folder)
00257         magic_ids = [item.getId() for item in evaluated]
00258         ids = []
00259         for magic_id in magic_ids:
00260             self.assertEqual(len(self.tool.concatenatedresources[magic_id]), 1)
00261             ids.append(self.tool.concatenatedresources[magic_id][0])
00262         self.failUnless(ids[0] == 'ham')
00263         self.failUnless(ids[1] == 'spam')

Here is the call graph for this function:

Definition at line 264 of file testJSRegistry.py.

00264 
00265     def testRenderingScriptLinks(self):
00266         self.tool.registerScript('ham')
00267         self.tool.registerScript('ham2merge')
00268         self.tool.registerScript('spam', expression='string:spam')
00269         self.tool.registerScript('test_rr_1.css', inline='1')
00270         view = self.portal.restrictedTraverse('@@plone')
00271         viewletmanager = getMultiAdapter((self.portal, self.portal.REQUEST, view), IContentProvider, name = u'plone.resourceregistries.scripts')
00272         viewletmanager.update()
00273         all = viewletmanager.render()
00274         evaluated = self.tool.getEvaluatedResources(self.folder)
00275         magic_ids = [item.getId() for item in evaluated]
00276         self.failUnless('background-color' in all)
00277         self.failUnless('<script' in all)
00278         self.failUnless('/%s' %(magic_ids[1],) in all)

Here is the call graph for this function:

Definition at line 289 of file testJSRegistry.py.

00289 
00290     def testRenderingWorksInMainTemplate(self):
00291         renderedpage = getattr(self.portal, 'index_html')()
00292         self.failIf('background-color' in renderedpage)
00293         self.tool.registerScript('test_rr_1.css', inline=1)
00294         renderedpage = getattr(self.portal, 'index_html')()
00295         self.failUnless('background-color' in renderedpage)
00296 

Here is the call graph for this function:

Definition at line 172 of file testJSRegistry.py.

00172 
00173     def testScriptCooking(self):
00174         self.tool.registerScript('ham')
00175         self.tool.registerScript('spam')
00176         self.tool.registerScript('eggs')
00177         self.assertEqual(len(self.tool.getResources()), 3)
00178         self.assertEqual(len(self.tool.cookedresources), 1)
00179         self.assertEqual(len(self.tool.concatenatedresources.keys()), 4)
00180         self.tool.setAutoGroupingMode(True)
00181         self.assertEqual(len(self.tool.getResources()), 3)
00182         self.assertEqual(len(self.tool.cookedresources), 1)
00183         self.assertEqual(len(self.tool.concatenatedresources.keys()), 4)

Definition at line 184 of file testJSRegistry.py.

00184 
00185     def testScriptCookingValues(self):
00186         self.tool.registerScript('ham')
00187         self.tool.registerScript('spam')
00188         self.tool.registerScript('eggs')
00189         self.assertEqual(self.tool.concatenatedresources[
00190                          self.tool.cookedresources[0].getId()],
00191                          ['ham', 'spam', 'eggs'])


Member Data Documentation

Definition at line 169 of file testJSRegistry.py.


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