r661 - in zope-resourceregistries/trunk: . debian doc tests tools
Fabio Tranchitella
kobold at alioth.debian.org
Fri Feb 9 15:47:51 CET 2007
Author: kobold
Date: 2007-02-09 15:47:50 +0100 (Fri, 09 Feb 2007)
New Revision: 661
Added:
zope-resourceregistries/trunk/._version.txt
zope-resourceregistries/trunk/tests/RegistryTestCase.py
zope-resourceregistries/trunk/tests/test.zcml
zope-resourceregistries/trunk/tests/testPacker.py
Removed:
zope-resourceregistries/trunk/tests/CSSRegistryTestCase.py
zope-resourceregistries/trunk/tests/five_tests_base.py
zope-resourceregistries/trunk/tests/framework.py
zope-resourceregistries/trunk/tests/interfaces.py
zope-resourceregistries/trunk/tests/runalltests.py
zope-resourceregistries/trunk/tests/testSkeleton.py
Modified:
zope-resourceregistries/trunk/README.txt
zope-resourceregistries/trunk/debian/changelog
zope-resourceregistries/trunk/doc/HISTORY.txt
zope-resourceregistries/trunk/tests/testCSSRegistry.py
zope-resourceregistries/trunk/tests/testHTTPHeaders.py
zope-resourceregistries/trunk/tests/testJSRegistry.py
zope-resourceregistries/trunk/tools/BaseRegistry.py
zope-resourceregistries/trunk/tools/CSSRegistry.py
zope-resourceregistries/trunk/tools/JSRegistry.py
zope-resourceregistries/trunk/tools/packer.py
zope-resourceregistries/trunk/version.txt
Log:
New upstream release.
Copied: zope-resourceregistries/trunk/._version.txt (from rev 637, zope-resourceregistries/branches/upstream/current/._version.txt)
Modified: zope-resourceregistries/trunk/README.txt
===================================================================
--- zope-resourceregistries/trunk/README.txt 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/README.txt 2007-02-09 14:47:50 UTC (rev 661)
@@ -47,27 +47,48 @@
rel -- Link relation. defaults to 'stylesheet', and should almost always
stay that way. For designating alternative stylesheets.
+ title -- the title for alternate stylesheets
+
rendering -- How to link the stylesheet from the html page:
- 'import' - the default. normal css import
- - 'link' - works better for old browsers an alternate stylesheets
+ - 'link' - works better for old browsers and is needed for alternate
+ stylesheets
- 'inline' - render the stylesheet inline instead of linking it
- externally. Use
- sparingly. Costs bandwidth, but is very useful for style that vary for
- example on a per-folder-basis, like those famous header graphics bars.
+ externally.
+ Shouldn't be used at all!
+ It isn't possible to create sites which validate if you do.
+ For more information see:
+ http://developer.mozilla.org/en/docs/Properly_Using_CSS_and_JavaScript_in_XHTML_Documents
compression -- Whether and how much the resource should be compressed:
- 'none' - the original content will not be changed
- 'safe' - the content will be compressed in a way which should be safe
- for any workarounds for browser bugs
+ for any workarounds for browser bugs. Conditional code for
+ Internet Explorer is preserved since ResourceRegistries
+ 1.2.3 and 1.3.1.
- - 'full' - the content will be heavily compressed, this might break some
- workarounds, only use this if you know what you are doing
+ - 'full' - the content will be compressed with some additional rules.
+ For css all comments and most newlines are removed, this may
+ break special browser hacks, so use with care.
+ For javascript this encodes variables with special prefixes
+ according to the rules described here (Special Characters):
+ http://dean.edwards.name/packer/usage/
+ The source code needs to be written according to those rules,
+ otherwise it's more than likely that it will break.
+ - 'safe-encode' - only available for javascript
+ - 'full-encode' - only available for javascript
+ Additionally encodes keywords. This heavily compresses the
+ javascript, but it needs to be decoded on the fly in the
+ browser on each load. Depending on the size of the scripts
+ this could lead to timeouts in Firefox.
+ Use with special care!
+
If several stylesheets listed directly after each other in the registry have
the same parameters and expression, they will be concatenated into a larger,
composite, stylesheet on rendering. - This can be useful for splitting
Modified: zope-resourceregistries/trunk/debian/changelog
===================================================================
--- zope-resourceregistries/trunk/debian/changelog 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/debian/changelog 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,3 +1,9 @@
+zope-resourceregistries (1.3.4-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Fabio Tranchitella <kobold at debian.org> Fri, 9 Feb 2007 15:47:40 +0100
+
zope-resourceregistries (1.3.2-1) unstable; urgency=low
* New upstream release.
Modified: zope-resourceregistries/trunk/doc/HISTORY.txt
===================================================================
--- zope-resourceregistries/trunk/doc/HISTORY.txt 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/doc/HISTORY.txt 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,3 +1,32 @@
+1.3.4
+=====
+
+ * Improved IE conditional compilation protection, it now works in "full"
+ compression.
+ [fschulze]
+
+ * Improved regular expression for strings.
+ [fschulze]
+
+ * Fixed order of oneline and multiline comment removal in javascript packer.
+ [fschulze]
+
+ * Fixed validation warning about multiple comments when rendering resources
+ inline.
+ [fschulze]
+
+ * Made css "full" packing more aggressive.
+ [fschulze]
+
+ * Cleaned up testing framework and made all tests run properly.
+ [fschulze, hannosch]
+
+1.3.3
+=====
+
+ * Don't wrap None in aquisition wrapper if resource is not found.
+ [tesdal]
+
1.3.2
=====
Deleted: zope-resourceregistries/trunk/tests/CSSRegistryTestCase.py
===================================================================
--- zope-resourceregistries/trunk/tests/CSSRegistryTestCase.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/CSSRegistryTestCase.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,20 +0,0 @@
-from Testing import ZopeTestCase
-
-ZopeTestCase.installProduct('ResourceRegistries')
-#ZopeTestCase.installProduct('Five')
-
-from Products.PloneTestCase import PloneTestCase
-
-PRODUCTS = ['ResourceRegistries']
-
-ZopeTestCase.utils.setupCoreSessions()
-PloneTestCase.setupPloneSite(products=PRODUCTS)
-
-class CSSRegistryTestCase(ZopeTestCase.Functional, PloneTestCase.PloneTestCase):
-
- class Session(dict):
- def set(self, key, value):
- self[key] = value
-
- def _setup(self):
- PloneTestCase.PloneTestCase._setup(self)
Copied: zope-resourceregistries/trunk/tests/RegistryTestCase.py (from rev 637, zope-resourceregistries/branches/upstream/current/tests/RegistryTestCase.py)
Deleted: zope-resourceregistries/trunk/tests/five_tests_base.py
===================================================================
--- zope-resourceregistries/trunk/tests/five_tests_base.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/five_tests_base.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,92 +0,0 @@
-'''\
-Set up tests with Five.
-'''
-
-import Products.ResourceRegistries.tests
-import Products.Five
-from Products.Five.zcml import load_string, load_config
-
-try:
- from zope.app.testing import placelesssetup
- run_setUp = True
-except ImportError:
- # Zope 2.8 / Five < 1.3
- from zope.app.tests import placelesssetup
- run_setUp = False
-
-class FiveTestsBase:
- 'Publishing with Five'
-
- def afterSetUp(self):
- if run_setUp:
- placelesssetup.setUp()
- # XXX I have absolutely no idea, why this fails on
- # Zope 2.8, however it seems to work fine without... ???
- # Allow traversing
- load_config('meta.zcml', package=Products.Five)
- load_config('configure.zcml', package=Products.Five)
- # Change to the context of this package
- Products.Five.zcml._context.package = Products.ResourceRegistries.tests
- load_string('''\
- <configure xmlns="http://namespaces.zope.org/zope"
- xmlns:five="http://namespaces.zope.org/five">
- <include package="zope.app.traversing" />
- <adapter
- for="*"
- factory="Products.Five.traversable.FiveTraversable"
- provides="zope.app.traversing.interfaces.ITraversable"
- />
- <adapter
- for="*"
- factory="zope.app.traversing.adapters.Traverser"
- provides="zope.app.traversing.interfaces.ITraverser"
- />
- </configure>''')
- # Enable Plone traversing
- load_string('''\
- <configure xmlns="http://namespaces.zope.org/zope"
- xmlns:five="http://namespaces.zope.org/five">
- <!-- IPortal binds to the portal root -->
-
- <interface
- interface=".interfaces.IPortal"
- type="zope.app.content.interfaces.IContentType"
- />
-
- <five:traversable class="Products.CMFPlone.Portal.PloneSite" />
-
- <content class="Products.CMFPlone.Portal.PloneSite">
- <implements
- interface=".interfaces.IPortal"
- />
- <!--require
- permission="zope.View"
- interface=".interfaces.IPortal"
- /-->
- </content>
-
- <!-- IPortalObject binds to all portal objects -->
-
- <interface
- interface=".interfaces.IPortalObject"
- type="zope.app.content.interfaces.IContentType"
- />
-
- <five:implements
- class="Products.CMFCore.PortalObject.PortalObjectBase"
- interface=".interfaces.IPortalObject"
- />
- <five:implements
- class="Products.Archetypes.public.BaseObject"
- interface=".interfaces.IPortalObject"
- />
-
- <five:traversable class="Products.CMFCore.PortalObject.PortalObjectBase" />
- <five:traversable class="Products.Archetypes.public.BaseObject" />
-
- </configure>''')
-
- def beforeTearDown(self):
- placelesssetup.tearDown()
- import Products.Five.zcml
- Products.Five.zcml._context = None
Deleted: zope-resourceregistries/trunk/tests/framework.py
===================================================================
--- zope-resourceregistries/trunk/tests/framework.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/framework.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,107 +0,0 @@
-##############################################################################
-#
-# ZopeTestCase
-#
-# COPY THIS FILE TO YOUR 'tests' DIRECTORY.
-#
-# This version of framework.py will use the SOFTWARE_HOME
-# environment variable to locate Zope and the Testing package.
-#
-# If the tests are run in an INSTANCE_HOME installation of Zope,
-# Products.__path__ and sys.path with be adjusted to include the
-# instance's Products and lib/python directories respectively.
-#
-# If you explicitly set INSTANCE_HOME prior to running the tests,
-# auto-detection is disabled and the specified path will be used
-# instead.
-#
-# If the 'tests' directory contains a custom_zodb.py file, INSTANCE_HOME
-# will be adjusted to use it.
-#
-# If you set the ZEO_INSTANCE_HOME environment variable a ZEO setup
-# is assumed, and you can attach to a running ZEO server (via the
-# instance's custom_zodb.py).
-#
-##############################################################################
-#
-# The following code should be at the top of every test module:
-#
-# import os, sys
-# if __name__ == '__main__':
-# execfile(os.path.join(sys.path[0], 'framework.py'))
-#
-# ...and the following at the bottom:
-#
-# if __name__ == '__main__':
-# framework()
-#
-##############################################################################
-
-__version__ = '0.2.3'
-
-# Save start state
-#
-__SOFTWARE_HOME = os.environ.get('SOFTWARE_HOME', '')
-__INSTANCE_HOME = os.environ.get('INSTANCE_HOME', '')
-
-if __SOFTWARE_HOME.endswith(os.sep):
- __SOFTWARE_HOME = os.path.dirname(__SOFTWARE_HOME)
-
-if __INSTANCE_HOME.endswith(os.sep):
- __INSTANCE_HOME = os.path.dirname(__INSTANCE_HOME)
-
-# Find and import the Testing package
-#
-if not sys.modules.has_key('Testing'):
- p0 = sys.path[0]
- if p0 and __name__ == '__main__':
- os.chdir(p0)
- p0 = ''
- s = __SOFTWARE_HOME
- p = d = s and s or os.getcwd()
- while d:
- if os.path.isdir(os.path.join(p, 'Testing')):
- zope_home = os.path.dirname(os.path.dirname(p))
- sys.path[:1] = [p0, p, zope_home]
- break
- p, d = s and ('','') or os.path.split(p)
- else:
- print 'Unable to locate Testing package.',
- print 'You might need to set SOFTWARE_HOME.'
- sys.exit(1)
-
-import Testing, unittest
-execfile(os.path.join(os.path.dirname(Testing.__file__), 'common.py'))
-
-# Include ZopeTestCase support
-#
-if 1: # Create a new scope
-
- p = os.path.join(os.path.dirname(Testing.__file__), 'ZopeTestCase')
-
- if not os.path.isdir(p):
- print 'Unable to locate ZopeTestCase package.',
- print 'You might need to install ZopeTestCase.'
- sys.exit(1)
-
- ztc_common = 'ztc_common.py'
- ztc_common_global = os.path.join(p, ztc_common)
-
- f = 0
- if os.path.exists(ztc_common_global):
- execfile(ztc_common_global)
- f = 1
- if os.path.exists(ztc_common):
- execfile(ztc_common)
- f = 1
-
- if not f:
- print 'Unable to locate %s.' % ztc_common
- sys.exit(1)
-
-# Debug
-#
-print 'SOFTWARE_HOME: %s' % os.environ.get('SOFTWARE_HOME', 'Not set')
-print 'INSTANCE_HOME: %s' % os.environ.get('INSTANCE_HOME', 'Not set')
-sys.stdout.flush()
-
Deleted: zope-resourceregistries/trunk/tests/interfaces.py
===================================================================
--- zope-resourceregistries/trunk/tests/interfaces.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/interfaces.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,14 +0,0 @@
-
-from zope.interface import Interface
-
-class IPortal(Interface):
- 'The portal root'
- pass
-
-class IPortalObject(Interface):
- 'All portal objects'
- pass
-
-class IReindexable(Interface):
- def reindexObject():
- '''update catalogs'''
Deleted: zope-resourceregistries/trunk/tests/runalltests.py
===================================================================
--- zope-resourceregistries/trunk/tests/runalltests.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/runalltests.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,29 +0,0 @@
-#
-# Runs all tests in the current directory
-#
-# Execute like:
-# python runalltests.py
-#
-# Alternatively use the testrunner:
-# python /path/to/Zope/utilities/testrunner.py -qa
-#
-
-import os, sys
-if __name__ == '__main__':
- execfile(os.path.join(sys.path[0], 'framework.py'))
-
-import unittest
-TestRunner = unittest.TextTestRunner
-suite = unittest.TestSuite()
-
-tests = os.listdir(os.curdir)
-tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]
-
-for test in tests:
- m = __import__(test)
- if hasattr(m, 'test_suite'):
- suite.addTest(m.test_suite())
-
-if __name__ == '__main__':
- TestRunner().run(suite)
-
Copied: zope-resourceregistries/trunk/tests/test.zcml (from rev 637, zope-resourceregistries/branches/upstream/current/tests/test.zcml)
Modified: zope-resourceregistries/trunk/tests/testCSSRegistry.py
===================================================================
--- zope-resourceregistries/trunk/tests/testCSSRegistry.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/testCSSRegistry.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -7,8 +7,6 @@
execfile(os.path.join(sys.path[0], 'framework.py'))
from textwrap import dedent
-from Testing import ZopeTestCase
-
from App.Common import rfc1123_date
from DateTime import DateTime
from zExceptions import NotFound
@@ -17,22 +15,22 @@
from Products.CMFCore.utils import getToolByName
-from Products.PloneTestCase.PloneTestCase import PLONE21
+from Products.PloneTestCase.PloneTestCase import PLONE21, portal_owner, default_password
from Products.ResourceRegistries.config import CSSTOOLNAME
from Products.ResourceRegistries.interfaces.ResourceRegistries import ICSSRegistry as z2ICSSRegistry
-from Products.ResourceRegistries.tests import CSSRegistryTestCase
-from Products.ResourceRegistries.tests.five_tests_base import FiveTestsBase
+from Products.ResourceRegistries.tests.RegistryTestCase import RegistryTestCase
+from Products.ResourceRegistries.tests.RegistryTestCase import FunctionalRegistryTestCase
-class TestImplementation(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestImplementation(RegistryTestCase):
def test_interfaces(self):
tool = getattr(self.portal, CSSTOOLNAME)
self.failUnless(z2ICSSRegistry.isImplementedBy(tool))
self.failUnless(verifyObject(z2ICSSRegistry, tool))
-class TestTool(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestTool(RegistryTestCase):
def testToolExists(self):
self.failUnless(CSSTOOLNAME in self.portal.objectIds())
@@ -44,7 +42,7 @@
self.failUnless(tool.manage_cssComposition())
-class TestSkin(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestSkin(RegistryTestCase):
def testSkins(self):
skins = self.portal.portal_skins.objectIds()
@@ -54,7 +52,7 @@
self.failUnless(getattr(self.portal, 'renderAllTheStylesheets'))
-class testZMIMethods(CSSRegistryTestCase.CSSRegistryTestCase):
+class testZMIMethods(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -66,7 +64,7 @@
self.failUnless(self.tool.getResources())
-class TestStylesheetRegistration(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestStylesheetRegistration(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -129,7 +127,7 @@
self.assertEqual(self.tool.getResourcesDict()['ham'].getId(), 'ham')
-class TestStylesheetRenaming(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestStylesheetRenaming(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -161,7 +159,7 @@
self.assertRaises(ValueError, self.tool.renameResource, 'spam', 'bacon')
-class TestToolSecurity(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestToolSecurity(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -180,7 +178,7 @@
self.fail()
-class TestToolExpression(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestToolExpression(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -204,7 +202,7 @@
'python:"eggs" in object.objectIds()', context))
-class TestStylesheetCooking(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestStylesheetCooking(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -335,7 +333,7 @@
self.failUnless('background-color' in renderedpage)
-class TestStylesheetMoving(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestStylesheetMoving(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -452,7 +450,7 @@
('bacon', 'spam', 'eggs', 'ham'))
-class TestTraversal(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestTraversal(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -495,7 +493,7 @@
self.failUnless('background-color : red' in content)
self.failUnless('H1 { color: blue; }' in content)
-class TestZODBTraversal(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestZODBTraversal(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -571,7 +569,7 @@
self.failUnless('purple' in content)
self.failIf('pink' in content)
-class TestMergingDisabled(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestMergingDisabled(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -698,7 +696,7 @@
content = str(self.portal.restrictedTraverse('portal_css/test_rr_2.css'))
self.failUnless('blue' in content)
-class TestPublishing(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestPublishing(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -713,7 +711,7 @@
def testPublishCSSThroughTool(self):
response = self.publish(self.toolpath + '/plone_styles.css')
self.assertEqual(response.getStatus(), 200)
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
def testPublishNonMagicCSSThroughTool(self):
self.setRoles(['Manager'])
@@ -722,7 +720,7 @@
self.tool.registerStylesheet('testmethod')
response = self.publish(self.toolpath + '/testmethod')
self.assertEqual(response.getStatus(), 200)
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
def testPublishPageWithInlineCSS(self):
response = self.publish(self.portalpath)
@@ -740,23 +738,14 @@
self.assertEqual(response.getStatus(), 200)
-class TestFivePublishing(CSSRegistryTestCase.CSSRegistryTestCase, FiveTestsBase):
+class TestFivePublishing(FunctionalRegistryTestCase):
'Publishing with Five'
def afterSetUp(self):
- FiveTestsBase.afterSetUp(self)
# Define some resource
- from Products.Five.zcml import load_string, load_config
- load_string(dedent('''\
- <configure xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- xmlns:five="http://namespaces.zope.org/five">
- <browser:resource
- name="test_rr_1.css"
- file="test_rr_1.css"
- />
- </configure>'''))
- #
+ from Products.Five.zcml import load_config
+ import Products.ResourceRegistries.tests
+ load_config('test.zcml', Products.ResourceRegistries.tests)
self.tool = getattr(self.portal, CSSTOOLNAME)
self.tool.clearResources()
self.tool.registerStylesheet('++resource++test_rr_1.css')
@@ -773,7 +762,7 @@
self.assertEqual('body { background-color : red }' in response.getBody(), True)
-class TestResourcePermissions(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestResourcePermissions(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -788,7 +777,7 @@
content_type='text/css',
file='body { background-color : green }')
- stylesheet = self.portal.restrictedTraverse('testroot.css')
+ stylesheet = getattr(self.portal, 'testroot.css')
stylesheet.manage_permission('View',['Manager'], acquire=0)
stylesheet.manage_permission('Access contents information',['Manager'], acquire=0)
@@ -852,13 +841,11 @@
self.fail()
def testAuthorizedOnPublish(self):
- # FIXME - As a manager this should be accessible, but the test doesn't work
- # when tested by hand in the browser, it does work as expected
- self.setRoles(['Manager'])
- response = self.publish(self.toolpath + '/testroot.css')
+ authstr = "%s:%s" % (portal_owner, default_password)
+ response = self.publish(self.toolpath + '/testroot.css', basic=authstr)
self.failUnlessEqual(response.getStatus(), 200)
-class TestDebugMode(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestDebugMode(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -895,51 +882,12 @@
self.assertEqual(response.getHeader('Cache-Control'), 'max-age=0')
-class TestCSSDefaults(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestResourceObjects(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
-
- def testClearingStylesheets(self):
- self.failUnless(self.tool.getResources())
self.tool.clearResources()
- self.failIf(self.tool.getResources())
- def testDefaultsInstall(self):
- stylesheetids = self.tool.getResourceIds()
- self.failUnless('plone.css' in stylesheetids)
- self.failUnless('ploneColumns.css' in stylesheetids)
- self.failUnless('ploneCustom.css' in stylesheetids)
-
- def testTraverseToConcatenatedDefaults(self):
- stylesheets = self.tool.getEvaluatedResources(self.portal)
- for s in stylesheets:
- try:
- magicId = s.getId()
- self.portal.restrictedTraverse('portal_css/%s' % magicId)
- except KeyError:
- self.fail()
-
- def testCallingOfConcatenatedStylesheets(self):
- stylesheets = self.tool.getEvaluatedResources(self.portal)
- for s in stylesheets:
- if 'ploneStyles' in s.getId():
- output = self.portal.restrictedTraverse('portal_css/%s' % s.getId())
- break
- if not output:
- self.fail()
- o = str(output)[:]
- self.failIf('<dtml-call' in o)
- self.failIf('&dtml-fontBaseSize;' in o)
- self.failUnless('** Plone style sheet for CSS2-capable browsers.' in o)
-
-
-class TestResourceObjects(CSSRegistryTestCase.CSSRegistryTestCase):
-
- def afterSetUp(self):
- self.tool = getattr(self.portal, CSSTOOLNAME)
- self.tool.clearResources()
-
def testSetEnabled(self):
self.tool.registerStylesheet('ham')
self.tool.registerStylesheet('spam')
@@ -981,7 +929,7 @@
['eggs'])
-class TestSkinAwareness(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestSkinAwareness(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -1022,177 +970,6 @@
self.failUnless('purple' in str(response))
-class TestCSSCompression(CSSRegistryTestCase.CSSRegistryTestCase):
- def afterSetUp(self):
- self.tool = getattr(self.portal, CSSTOOLNAME)
-
- def testCommentCompression(self):
- input = """
- /* this is a comment */
- #testElement {
- property: value; /* another comment */
- }
- /**********/
- /* this is a multi
- line comment */
- #testElement {
- /* yet another comment */
- property: value;
- }
- """
- expected = """/* */
-#testElement {
-property: value; /* */
-}
-/* */
-#testElement {
-/* */
-property: value;
-}
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testNewlineCompression(self):
- input = """
-
-
- /* this is a comment */
-
- #testElement {
- property: value; /* another comment */
- }
-
- /* this is a multi
- line comment */
- #testElement {
-
- /* yet another comment */
- property: value;
-
- }
-
-
- """
- expected = """/* */
-#testElement {
-property: value; /* */
-}
-/* */
-#testElement {
-/* */
-property: value;
-}
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testCommentHacks(self):
- # see http://www.dithered.com/css_filters/index.html
- input = """
- #testElement {
- property/**/: value;
- property/* */: value;
- property /**/: value;
- property: /**/value;
- }
- """
- expected = """#testElement {
-property/**/: value;
-property/* */: value;
-property /**/: value;
-property: /**/value;
-}
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- selector/* */ { }
- """
- expected = """selector/* */ { }
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- selector/* foobar */ { }
- """
- expected = """selector/* */ { }
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- selector/**/ { }
- """
- expected = """selector/**/ { }
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- /* \*/
- rules
- /* */
- """
- expected = """/* \*/
-rules
-/* */
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- /* foobar \*/
- rules
- /* */
- """
- expected = """/* \*/
-rules
-/* */
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- /*/*/
- rules
- /* */
- """
- expected = """/*/*/
-rules
-/* */
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- /*/*//*/
- rules
- /* */
- """
- expected = """/*/*//*/
-rules
-/* */
-"""
- got = self.tool._compressCSS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = """
- /* test string protection and full compression */
- #selector,
- #another {
- content: 'foo; bar';
- }
- """
- expected = """/* */
-#selector,#another {content: 'foo; bar';}
-"""
- got = self.tool._compressCSS(input, 'full')
- self.assertEqual(got, expected)
-
-
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
@@ -1215,14 +992,7 @@
suite.addTest(makeSuite(TestDebugMode))
suite.addTest(makeSuite(TestResourceObjects))
suite.addTest(makeSuite(TestSkinAwareness))
- suite.addTest(makeSuite(TestCSSCompression))
- if not PLONE21:
- # We must not test for the defaults in Plone 2.1 because they are
- # all different. Plone2.1 has tests in CMFPlone/tests for defaults
- # and migrations
- suite.addTest(makeSuite(TestCSSDefaults))
-
return suite
if __name__ == '__main__':
Modified: zope-resourceregistries/trunk/tests/testHTTPHeaders.py
===================================================================
--- zope-resourceregistries/trunk/tests/testHTTPHeaders.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/testHTTPHeaders.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -6,8 +6,6 @@
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
-from Testing import ZopeTestCase
-
from App.Common import rfc1123_date
from DateTime import DateTime
from zExceptions import NotFound
@@ -20,9 +18,9 @@
from Products.ResourceRegistries.config import CSSTOOLNAME
from Products.ResourceRegistries.interfaces import ICSSRegistry
-from Products.ResourceRegistries.tests import CSSRegistryTestCase
+from Products.ResourceRegistries.tests.RegistryTestCase import FunctionalRegistryTestCase
-class TestHTTPHeaders(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestHTTPHeaders(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, CSSTOOLNAME)
@@ -37,7 +35,7 @@
self.portal.addDTMLMethod('testmethod', file="""<dtml-call "REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')">""")
self.tool.registerStylesheet('testmethod')
response = self.publish(self.toolpath+'/testmethod')
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
self.assertEqual(response.getStatus(), 200)
def testIfModifiedSinceHeaders(self):
@@ -50,7 +48,7 @@
self.tool.registerStylesheet('testmethod')
response = self.publish(self.toolpath+'/testmethod', env={'IF_MODIFIED_SINCE': rfc1123_date((DateTime() - 60.0/(24.0*3600.0)))})
#response = self.publish(self.toolpath+'/testmethod')
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
self.assertEqual(response.getStatus(), 200) # this should in fact send a 200
# we also add an fsfile for good measure
@@ -58,7 +56,7 @@
rs = self.tool.getEvaluatedResources(self.portal)
response = self.publish(self.toolpath+'/test_rr_2.css', env={'IF_MODIFIED_SINCE': rfc1123_date((DateTime() - 60.0/(24.0*3600.0)))})
self.assertEqual(response.getStatus(), 200) # this should send a 200 when things are fixed, but right now should send a 304
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
#response = self.publish(self.toolpath+'/test_rr_2.css')
#self.assertEqual(response.getStatus(), 200) # this should send a 200 when things are fixed, but right now should send a 304
@@ -81,7 +79,7 @@
rs = self.tool.getEvaluatedResources(self.portal)
self.assertEqual(len(rs),1)
response = self.publish(self.toolpath+'/'+rs[0].getId())
- self.assertEqual(response.getHeader('Content-Type'), 'text/css')
+ self.assertEqual(response.getHeader('Content-Type'), 'text/css;charset=utf-8')
#print str(response)
self.assertEqual(int(response.getHeader('content-length')), len(response.getBody()))
self.assertEqual(response.getStatus(), 200)
Modified: zope-resourceregistries/trunk/tests/testJSRegistry.py
===================================================================
--- zope-resourceregistries/trunk/tests/testJSRegistry.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/testJSRegistry.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -7,8 +7,6 @@
execfile(os.path.join(sys.path[0], 'framework.py'))
from textwrap import dedent
-from Testing import ZopeTestCase
-
from App.Common import rfc1123_date
from DateTime import DateTime
from zExceptions import NotFound
@@ -17,23 +15,23 @@
from Products.CMFCore.utils import getToolByName
-from Products.PloneTestCase.PloneTestCase import PLONE21
+from Products.PloneTestCase.PloneTestCase import PLONE21, portal_owner, default_password
from Products.ResourceRegistries.config import JSTOOLNAME
from Products.ResourceRegistries.interfaces import IJSRegistry
-from Products.ResourceRegistries.tests import CSSRegistryTestCase
-from Products.ResourceRegistries.tests.five_tests_base import FiveTestsBase
+from Products.ResourceRegistries.tests.RegistryTestCase import RegistryTestCase
+from Products.ResourceRegistries.tests.RegistryTestCase import FunctionalRegistryTestCase
+from Products.ResourceRegistries.tools.packer import test_suite as packer_tests
+class TestJSImplementation(RegistryTestCase):
-class TestJSImplementation(CSSRegistryTestCase.CSSRegistryTestCase):
-
def test_interfaces(self):
tool = getattr(self.portal, JSTOOLNAME)
self.failUnless(IJSRegistry.isImplementedBy(tool))
self.failUnless(verifyObject(IJSRegistry, tool))
-class TestJSTool(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSTool(RegistryTestCase):
def testToolExists(self):
self.failUnless(JSTOOLNAME in self.portal.objectIds())
@@ -45,7 +43,7 @@
self.failUnless(tool.manage_jsComposition())
-class TestJSSkin(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSSkin(RegistryTestCase):
def testSkins(self):
skins = self.portal.portal_skins.objectIds()
@@ -55,7 +53,7 @@
self.failUnless(getattr(self.portal, 'renderAllTheScripts'))
-class testJSZMIMethods(CSSRegistryTestCase.CSSRegistryTestCase):
+class testJSZMIMethods(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -67,7 +65,7 @@
self.failUnless(self.tool.getResources())
-class TestJSScriptRegistration(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSScriptRegistration(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -94,7 +92,7 @@
self.assertEqual(len(self.tool.getResources()), 0)
-class TestJSScriptRenaming(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSScriptRenaming(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -126,7 +124,7 @@
self.assertRaises(ValueError, self.tool.renameResource, 'spam', 'bacon')
-class TestJSToolSecurity(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSToolSecurity(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -145,7 +143,7 @@
self.fail()
-class TestJSToolExpression(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSToolExpression(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -169,7 +167,7 @@
'python:"eggs" in object.objectIds()', context))
-class TestJSScriptCooking(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSScriptCooking(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -272,7 +270,7 @@
self.failUnless('background-color' in renderedpage)
-class TestScriptMoving(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestScriptMoving(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -382,7 +380,7 @@
self.assertEqual(self.tool.getResourceIds(),
('bacon', 'spam', 'eggs', 'ham'))
-class TestJSTraversal(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestJSTraversal(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -419,17 +417,15 @@
content = str(self.portal.restrictedTraverse('portal_javascripts/%s' % magicId))
-class TestPublishing(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestPublishing(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
self.tool.clearResources()
self.toolpath = '/' + self.tool.absolute_url(1)
- self.portalpath = '/' + getToolByName(self.portal, 'portal_url')(1)
+ self.folderpath = '/' + self.folder.absolute_url(1)
self.tool.registerScript('test_rr_1.js')
- self.setRoles(['Manager'])
- self.portal.invokeFactory('Document', 'index_html')
- self.setRoles(['Member'])
+ self.folder.invokeFactory('Document', 'index_html')
def testPublishJSThroughTool(self):
response = self.publish(self.toolpath + '/test_rr_1.js')
@@ -439,7 +435,7 @@
def testPublishNonMagicJSThroughTool(self):
self.setRoles(['Manager'])
body = """<dtml-var "'joined' + 'string'">"""
- self.portal.addDTMLMethod('testmethod', file=body)
+ self.folder.addDTMLMethod('testmethod', file=body)
self.tool.registerScript('testmethod')
response = self.publish(self.toolpath + '/testmethod')
self.assertEqual(response.getStatus(), 200)
@@ -447,14 +443,14 @@
def testPublishPageWithInlineJS(self):
# This one fails from string/utf-8 concatenation
- response = self.publish(self.portalpath)
+ response = self.publish(self.folderpath)
self.assertEqual(response.getStatus(), 200)
self.assertEqual(response.getHeader('Content-Type'),
'text/html;charset=utf-8')
self.tool.clearResources()
self.tool.registerScript('test_rr_1.js', inline=True)
# Test that the main page retains its content-type
- response = self.publish(self.portalpath)
+ response = self.publish(self.folderpath)
self.assertEqual(response.getHeader('Content-Type'),
'text/html;charset=utf-8')
self.assertEqual(response.getStatus(), 200)
@@ -464,30 +460,21 @@
# Test that the main page retains its content-type
self.setRoles(['Manager'])
body = """<dtml-call "REQUEST.RESPONSE.setHeader('Content-Type', 'text/javascript')">/*and some js comments too*/ """
- self.portal.addDTMLMethod('testmethod', file=body)
+ self.folder.addDTMLMethod('testmethod', file=body)
self.tool.registerScript('testmethod', inline=True)
- response = self.publish(self.portalpath)
+ response = self.publish(self.folderpath)
self.assertEqual(response.getHeader('Content-Type'),
'text/html;charset=utf-8')
self.assertEqual(response.getStatus(), 200)
-class TestFivePublishing(CSSRegistryTestCase.CSSRegistryTestCase, FiveTestsBase):
+class TestFivePublishing(FunctionalRegistryTestCase):
'Publishing with Five'
def afterSetUp(self):
- FiveTestsBase.afterSetUp(self)
# Define some resource
- from Products.Five.zcml import load_string, load_config
- load_string(dedent('''\
- <configure xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- xmlns:five="http://namespaces.zope.org/five">
- <browser:resource
- name="test_rr_1.js"
- file="test_rr_1.js"
- />
- </configure>'''))
- #
+ from Products.Five.zcml import load_config
+ import Products.ResourceRegistries.tests
+ load_config('test.zcml', Products.ResourceRegistries.tests)
self.tool = getattr(self.portal, JSTOOLNAME)
self.tool.clearResources()
self.tool.registerScript('++resource++test_rr_1.js')
@@ -503,7 +490,7 @@
self.assertEqual(response.getHeader('Content-Type')[:24], 'application/x-javascript')
self.assertEqual("window.alert('running')" in response.getBody(), True)
-class TestDebugMode(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestDebugMode(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -540,58 +527,11 @@
self.assertEqual(response.getHeader('Cache-Control'), 'max-age=0')
-class TestJSDefaults(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestZODBTraversal(RegistryTestCase):
- # These do not run for plone 2.1 +
-
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
-
- def testClearingScripts(self):
- self.failUnless(self.tool.getResources())
self.tool.clearResources()
- self.failIf(self.tool.getResources())
-
- def testDefaultsInstall(self):
- scriptids = self.tool.getResourceIds()
- self.failUnless('plone_menu.js' in scriptids)
- self.failUnless('plone_javascript_variables.js' in scriptids)
- self.failUnless('test_rr_1.js' in scriptids)
-
- def testTraverseToConcatenatedDefaults(self):
- scripts = self.tool.getEvaluatedResources(self.portal)
- for s in scripts:
- try:
- magic = s.getId()
- self.portal.restrictedTraverse('portal_javascripts/%s' % magic)
- except KeyError:
- self.fail()
-
- def testUserConditionOnMenuScript(self):
- scripts1 = self.tool.getEvaluatedResources(self.portal)
- self.logout()
- scripts2 = self.tool.getEvaluatedResources(self.portal)
- self.failUnless(len(scripts1) > len(scripts2))
-
- def testCallingOfConcatenatedScripts(self):
- stylesheets = self.tool.getEvaluatedResources(self.portal)
- for s in stylesheets:
- if 'ploneScripts' in s.getId():
- output = self.portal.restrictedTraverse(
- 'portal_javascripts/%s' % s.getId())
- break
- if not output:
- self.fail()
- o = str(output)[:]
- self.failIf('<dtml-call' in o)
- self.failIf('&dtml' in o)
- self.failUnless('portal_url' in o)
-
-class TestZODBTraversal(CSSRegistryTestCase.CSSRegistryTestCase):
-
- def afterSetUp(self):
- self.tool = getattr(self.portal, JSTOOLNAME)
- self.tool.clearResources()
self.setRoles(['Manager'])
self.portal.invokeFactory('File',
id='testroot.js',
@@ -662,7 +602,7 @@
self.failUnless('purple' in content)
self.failIf('pink' in content)
-class TestResourcePermissions(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestResourcePermissions(FunctionalRegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -754,13 +694,11 @@
self.fail()
def testAuthorizedOnPublish(self):
- # FIXME - As a manager this should be accessible, but the test doesn't work
- # when tested by hand in the browser, it does work as expected
- self.setRoles(['Manager'])
- response = self.publish(self.toolpath + '/testroot.js')
+ authstr = "%s:%s" % (portal_owner, default_password)
+ response = self.publish(self.toolpath + '/testroot.js', basic=authstr)
self.failUnlessEqual(response.getStatus(), 200)
-class TestMergingDisabled(CSSRegistryTestCase.CSSRegistryTestCase):
+class TestMergingDisabled(RegistryTestCase):
def afterSetUp(self):
self.tool = getattr(self.portal, JSTOOLNAME)
@@ -892,65 +830,7 @@
content = str(self.portal.restrictedTraverse('portal_javascripts/simple2.js'))
self.failUnless('blue' in content)
-class TestJSCompression(CSSRegistryTestCase.CSSRegistryTestCase):
- def afterSetUp(self):
- self.tool = getattr(self.portal, JSTOOLNAME)
- def testCompression(self):
- input = """
-/* a comment */
-
-function dummy() {
-
- var localvar = 10 // one line comment
-
- document.write(localvar);
- return 'bar'
-}
-"""
- expected = """function dummy(){var localvar=10
-document.write(localvar);return 'bar'}
-"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testStringProtection(self):
- input = """
-var leafnode = this.shared.xmldata.selectSingleNode('//*[@selected]');
-var portal_url = 'http://127.0.0.1:9080/plone';
-"""
- expected = """var leafnode=this.shared.xmldata.selectSingleNode('//*[@selected]');var portal_url='http://127.0.0.1:9080/plone';"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testNewlinesInStrings(self):
- input = r"""var message = "foo: " + foo + "\nbar: " + bar;"""
- expected = r"""var message="foo: "+foo+"\nbar: "+bar;"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testEscapedStrings(self):
- input = r"""var message = "foo: \"something in quotes\"" + foo + "\nbar: " + bar;"""
- expected = r"""var message="foo: \"something in quotes\""+foo+"\nbar: "+bar;"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
- def testWhitspaceAroundPlusMinus(self):
- input = r"""var message = foo + bar;
-message = foo++ + bar;
-message = foo + ++bar;"""
- expected = r"""var message=foo+bar;message=foo++ +bar;message=foo+ ++bar;"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
- input = r"""var message = foo - bar;
-message = foo-- - bar;
-message = foo - --bar;"""
- expected = r"""var message=foo-bar;message=foo-- -bar;message=foo- --bar;"""
- got = self.tool._compressJS(input, 'safe')
- self.assertEqual(got, expected)
-
-
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
@@ -971,15 +851,7 @@
suite.addTest(makeSuite(TestZODBTraversal))
suite.addTest(makeSuite(TestMergingDisabled))
suite.addTest(makeSuite(TestResourcePermissions))
- suite.addTest(makeSuite(TestJSCompression))
- if not PLONE21:
- # We must not test for the defaults in Plone 2.1 because they are
- # all different. Plone2.1 has tests in CMFPlone/tests for defaults
- # and migrations
- suite.addTest(makeSuite(TestJSDefaults))
-
-
return suite
if __name__ == '__main__':
Copied: zope-resourceregistries/trunk/tests/testPacker.py (from rev 637, zope-resourceregistries/branches/upstream/current/tests/testPacker.py)
Deleted: zope-resourceregistries/trunk/tests/testSkeleton.py
===================================================================
--- zope-resourceregistries/trunk/tests/testSkeleton.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tests/testSkeleton.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,30 +0,0 @@
-#
-# ResourcesRegistry Skeleton
-#
-
-import os, sys
-if __name__ == '__main__':
- execfile(os.path.join(sys.path[0], 'framework.py'))
-
-from Testing import ZopeTestCase
-from Products.ResourceRegistries.tests import CSSRegistryTestCase
-
-
-class TestSomething(CSSRegistryTestCase.CSSRegistryTestCase):
-
- def afterSetUp(self):
- pass
-
- def testSomething(self):
- # Test something
- self.assertEqual(1+1, 2)
-
-
-def test_suite():
- from unittest import TestSuite, makeSuite
- suite = TestSuite()
- suite.addTest(makeSuite(TestSomething))
- return suite
-
-if __name__ == '__main__':
- framework()
Modified: zope-resourceregistries/trunk/tools/BaseRegistry.py
===================================================================
--- zope-resourceregistries/trunk/tools/BaseRegistry.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tools/BaseRegistry.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -435,7 +435,10 @@
If any property of the resource is changed, then cookResources of the
registry must be called."""
resources = self.getResourcesDict()
- return ExplicitAcquisitionWrapper(resources.get(id, None), self)
+ resource = resources.get(id, None)
+ if resource is not None:
+ return ExplicitAcquisitionWrapper(resource, self)
+ return None
security.declarePrivate('getResourceContent')
def getResourceContent(self, item, context, original=False):
@@ -527,7 +530,7 @@
# Add start/end notes to the resource for better
# understanding and debugging
if content:
- output += '\n/* ----- %s ----- */\n' % (id,)
+ output += '\n/* - %s - */\n' % (id,)
if original:
output += content
else:
Modified: zope-resourceregistries/trunk/tools/CSSRegistry.py
===================================================================
--- zope-resourceregistries/trunk/tools/CSSRegistry.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tools/CSSRegistry.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -297,7 +297,18 @@
security.declareProtected(permissions.View, 'getContentType')
def getContentType(self):
"""Return the registry content type."""
- return 'text/css'
+ plone_utils = getToolByName(self, 'plone_utils')
+ try:
+ encoding = plone_utils.getSiteEncoding()
+ except AttributeError:
+ # For Plone < 2.1
+ pprop = getToolByName(self, 'portal_properties')
+ default = 'utf-8'
+ try:
+ encoding = pprop.site_properties.getProperty('default_charset', default)
+ except AttributeError:
+ encoding = default
+ return 'text/css;charset=%s' % encoding
InitializeClass(CSSRegistryTool)
Modified: zope-resourceregistries/trunk/tools/JSRegistry.py
===================================================================
--- zope-resourceregistries/trunk/tools/JSRegistry.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tools/JSRegistry.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -96,7 +96,7 @@
* Some of these parts have 3rd party licenses or copyright information attached
* Such information is valid for that section,
* not for the entire composite file
- * originating files are separated by ----- filename.js -----
+ * originating files are separated by - filename.js -
*/
"""
resource_class = JavaScript
Modified: zope-resourceregistries/trunk/tools/packer.py
===================================================================
--- zope-resourceregistries/trunk/tools/packer.py 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/tools/packer.py 2007-02-09 14:47:50 UTC (rev 661)
@@ -1,4 +1,4 @@
-import re
+import re, unittest, textwrap
class KeywordMapper:
@@ -221,13 +221,12 @@
# store protected part
self.replacelist.append(match.group(1))
# return escaped index
- return "\x00%i" % len(self.replacelist)
+ return "\x00%i\x00" % len(self.replacelist)
def pack(self, input):
# list of protected parts
self.replacelist = []
- # escape the escapechar
- output = input.replace('\x00','\x00\x00')
+ output = input
for regexp, replacement, keyword_encoder in self.patterns:
if replacement is None:
if keyword_encoder is None:
@@ -250,10 +249,8 @@
# we use lambda in here, so the real string is used and no escaping
# is done on it
before = len(output)
- regexp = re.compile('(?<!\x00)\x00%i' % (index+1))
+ regexp = re.compile('\x00%i\x00' % (index+1))
output = regexp.sub(lambda m:replacement, output)
- # unescape
- output = output.replace('\x00\x00','\x00')
# done
return output
@@ -290,22 +287,32 @@
self.keywordSub(r"""\b_[A-Za-z\d]\w*""", lambda i: "_%i" % i)
- # protect strings
- # this is more correct, but needs more testing
- # it has to be more accurate because of the more aggresive packing later
- self.protect(r"""(?<=return|..case|.....[=\[|(,?:+])\s*((?P<quote>['"])(?:\\(?P=quote)|\\\n|.)*?(?P=quote))""", re.DOTALL)
- else:
- # protect strings
- # these sometimes catch to much, but in safe mode this doesn't hurt
- self.protect(r"""('(?:\\'|\\\n|.)*?')""")
- self.protect(r'''("(?:\\"|\\\n|.)*?")''')
+ # protect strings
+ # these sometimes catch to much, but in safe mode this doesn't hurt
+
+ # the parts:
+ # match a single quote
+ # match anything but the single quote, a backslash and a newline "[^'\\\n]"
+ # or match a null escape (\0 not followed by another digit) "\\0(?![0-9])"
+ # or match a character escape (no newline) "\\[^\n]"
+ # do this until there is another single quote "(?:<snip>)*?'"
+ # all this return one group "(<snip>)"
+ self.protect(r"""('(?:[^'\\\n]|\\0(?![0-9])|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\[^\n])*?')""")
+ # the same for double quotes
+ self.protect(r"""("(?:[^"\\\n]|\\0(?![0-9])|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\[^\n])*?")""")
+
# protect regular expressions
self.protect(r"""\s+(\/[^\/\n\r\*][^\/\n\r]*\/g?i?)""")
self.protect(r"""([^\w\$\/'"*)\?:]\/[^\/\n\r\*][^\/\n\r]*\/g?i?)""")
- # multiline comments
- self.sub(r'/\*(?!@).*?\*/', '', re.DOTALL)
- # one line comments
+
+ # protect IE conditional compilation
+ self.protect(r'(/\*@.*?(?:\*/|\n|\*/(?!\n)))', re.DOTALL)
+
+ # remove one line comments
self.sub(r'\s*//.*$', '', re.MULTILINE)
+ # remove multiline comments
+ self.sub(r'/\*.*?\*/', '', re.DOTALL)
+
# strip whitespace at the beginning and end of each line
self.sub(r'^[ \t\r\f\v]*(.*?)[ \t\r\f\v]*$', r'\1', re.MULTILINE)
# whitespace after some special chars but not
@@ -345,44 +352,726 @@
self.protect(r'''("(?:\\"|\\\n|.)*?")''')
# strip whitespace
self.sub(r'^[ \t\r\f\v]*(.*?)[ \t\r\f\v]*$', r'\1', re.MULTILINE)
- # remove comment contents
- self.sub(r'/\*.*?( ?[\\/*]*\*/)', r'/*\1', re.DOTALL)
- # remove lines with comments only (consisting of stars only)
- self.sub(r'^/\*+\*/$', '', re.MULTILINE)
+ if level == 'full':
+ # remove comments
+ self.sub(r'/\*.*? ?[\\/*]*\*/', r'', re.DOTALL)
+ #remove more whitespace
+ self.sub(r'\s*([{,;:])\s+', r'\1')
+ else:
+ # remove comment contents
+ self.sub(r'/\*.*?( ?[\\/*]*\*/)', r'/*\1', re.DOTALL)
+ # remove lines with comments only (consisting of stars only)
+ self.sub(r'^/\*+\*/$', '', re.MULTILINE)
# excessive newlines
self.sub(r'\n+', '\n')
# first newline
self.sub(r'^\n', '')
- if level == 'full':
- #remove more whitespace
- self.sub(r'([{,;])\s+', r'\1')
-## jspacker = JavascriptPacker('safe')
-## jspacker_full = JavascriptPacker('full')
+# be aware that the initial indentation gets removed in the following tests,
+# the inner indentation is preserved though (see textwrap.dedent)
+js_compression_tests = (
+ (
+ 'standardJS',
+ """\
+ /* a comment */
-## def run():
- ## script = open('cssQuery.js').read()
- ## script = jspacker_full.pack(script)
- ## open('output.js','w').write(script)
- ## mapper = JavascriptKeywordMapper()
- ## mapper.analyse(script)
- ## keywords = mapper.getKeywords()
- ## script = mapper.sub(script)
- ## f = open('output1.js','w')
- ## #f.write("keywords='%s'.split('|');\n" % "|".join(keywords))
- ## #f.write(mapper.getDecodeFunction(name='__dEcOdE'))
- ## f.write(mapper.getDecoder(script))
- ## for index, keyword in enumerate(keywords):
- ## encoded = mapper._encode(index)
- ## if keyword == '':
- ## replacement = encoded
- ## else:
- ## replacement = keyword
- ## regexp = re.compile(r'\b%s\b' % encoded)
- ## script = regexp.sub(lambda m: replacement, script)
- ## open('output2.js','w').write(script)
+ function dummy() {
-## if __name__=='__main__':
- ## run()
+ var localvar = 10 // one line comment
+
+ document.write(localvar);
+ return 'bar'
+ }
+ """,
+ """\
+ function dummy(){var localvar=10
+ document.write(localvar);return 'bar'}
+ """,
+ 'safe'
+ ),
+ (
+ 'standardJS',
+ """\
+ /* a comment */
+
+ function dummy() {
+
+ var localvar = 10 // one line comment
+
+ document.write(localvar);
+ return 'bar'
+ }
+ """,
+ """\
+ function dummy(){var localvar=10
+ document.write(localvar);return 'bar'}""",
+ 'full'
+ ),
+ (
+ 'stringProtection',
+ """
+ var leafnode = this.shared.xmldata.selectSingleNode('//*[@selected]');
+ var portal_url = 'http://127.0.0.1:9080/plone';
+ """,
+ """var leafnode=this.shared.xmldata.selectSingleNode('//*[@selected]');var portal_url='http://127.0.0.1:9080/plone';"""
+ ),
+ (
+ 'newlinesInStrings',
+ r"""var message = "foo: " + foo + "\nbar: " + bar;""",
+ r"""var message="foo: "+foo+"\nbar: "+bar;"""
+ ),
+ (
+ 'escapedStrings',
+ r"""var message = "foo: \"something in quotes\"" + foo + "\nbar: " + bar;""",
+ r"""var message="foo: \"something in quotes\""+foo+"\nbar: "+bar;"""
+ ),
+ (
+ 'escapedStrings2',
+ r"""kukit.kssp.string = kukit.tk.mkParser('string', {
+ "'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))',
+ "\\": 'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'
+ });
+ kukit.kssp.string.prototype.process = function() {
+ // collect up the value of the string, omitting the quotes
+ this.txt = '';
+ for (var i=1; i<this.result.length-1; i++) {
+ this.txt += this.result[i].txt;
+ }
+ };
+
+ kukit.kssp.string2 = kukit.tk.mkParser('string', {
+ '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.src))',
+ "\\": 'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'
+ });
+ kukit.kssp.string2.prototype.process = kukit.kssp.string.prototype.process;
+
+
+ kukit.kssp.backslashed = kukit.tk.mkParser('backslashed', {});
+ kukit.kssp.backslashed.prototype.nextStep = function(table) {
+ // digest the next character and store it as txt
+ var src = this.src;
+ var length = src.text.length;
+ if (length < src.pos + 1) {
+ this.emitError('Missing character after backslash');
+ } else {
+ this.result.push(new kukit.tk.Fraction(src, src.pos+1));
+ this.src.pos += 1;
+ this.finished = true;
+ }
+ };
+ kukit.kssp.backslashed.prototype.process = function() {
+ this.txt = this.result[1].txt;
+ };
+ """,
+ r"""kukit.kssp.string=kukit.tk.mkParser('string',{"'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))',"\\":'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'});kukit.kssp.string.prototype.process=function(){this.txt='';for(var i=1;i<this.result.length-1;i++){this.txt+=this.result[i].txt}};kukit.kssp.string2=kukit.tk.mkParser('string',{'"':'this.emitAndReturn(new kukit.kssp.dquote(this.src))',"\\":'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'});kukit.kssp.string2.prototype.process=kukit.kssp.string.prototype.process;kukit.kssp.backslashed=kukit.tk.mkParser('backslashed',{});kukit.kssp.backslashed.prototype.nextStep=function(table){var src=this.src;var length=src.text.length;if(length<src.pos+1){this.emitError('Missing character after backslash')} else{this.result.push(new kukit.tk.Fraction(src,src.pos+1));this.src.pos+=1;this.finished=true}};kukit.kssp.backslashed.prototype.process=function(){this.txt=this.result[1].txt};""",
+ 'safe'
+ ),
+ (
+ 'escapedStrings2',
+ r"""kukit.kssp.string = kukit.tk.mkParser('string', {
+ "'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))',
+ "\\": 'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'
+ });
+ kukit.kssp.string.prototype.process = function() {
+ // collect up the value of the string, omitting the quotes
+ this.txt = '';
+ for (var i=1; i<this.result.length-1; i++) {
+ this.txt += this.result[i].txt;
+ }
+ };
+
+ kukit.kssp.string2 = kukit.tk.mkParser('string', {
+ '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.src))',
+ "\\": 'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'
+ });
+ kukit.kssp.string2.prototype.process = kukit.kssp.string.prototype.process;
+
+
+ kukit.kssp.backslashed = kukit.tk.mkParser('backslashed', {});
+ kukit.kssp.backslashed.prototype.nextStep = function(table) {
+ // digest the next character and store it as txt
+ var src = this.src;
+ var length = src.text.length;
+ if (length < src.pos + 1) {
+ this.emitError('Missing character after backslash');
+ } else {
+ this.result.push(new kukit.tk.Fraction(src, src.pos+1));
+ this.src.pos += 1;
+ this.finished = true;
+ }
+ };
+ kukit.kssp.backslashed.prototype.process = function() {
+ this.txt = this.result[1].txt;
+ };
+ """,
+ r"""kukit.kssp.string=kukit.tk.mkParser('string',{"'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))',"\\":'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'});kukit.kssp.string.prototype.process=function(){this.txt='';for(var i=1;i<this.result.length-1;i++){this.txt+=this.result[i].txt}};kukit.kssp.string2=kukit.tk.mkParser('string',{'"':'this.emitAndReturn(new kukit.kssp.dquote(this.src))',"\\":'new kukit.kssp.backslashed(this.src, kukit.kssp.backslash)'});kukit.kssp.string2.prototype.process=kukit.kssp.string.prototype.process;kukit.kssp.backslashed=kukit.tk.mkParser('backslashed',{});kukit.kssp.backslashed.prototype.nextStep=function(table){var src=this.src;var length=src.text.length;if(length<src.pos+1){this.emitError('Missing character after backslash')}else{this.result.push(new kukit.tk.Fraction(src,src.pos+1));this.src.pos+=1;this.finished=true}};kukit.kssp.backslashed.prototype.process=function(){this.txt=this.result[1].txt};""",
+ 'full'
+ ),
+ (
+ 'whitspaceAroundPlus',
+ """\
+ var message = foo + bar;
+ message = foo++ + bar;
+ message = foo + ++bar;
+ """,
+ """\
+ var message=foo+bar;message=foo++ +bar;message=foo+ ++bar;"""
+ ),
+ (
+ 'whitspaceAroundMinus',
+ """\
+ var message = foo - bar;
+ message = foo-- - bar;
+ message = foo - --bar;
+ """,
+ """\
+ var message=foo-bar;message=foo-- -bar;message=foo- --bar;"""
+ ),
+ (
+ 'missingSemicolon',
+ """\
+ var x = function() {
+
+ } /* missing ; here */
+ next_instr;
+ """,
+ """\
+ var x=function(){}
+ next_instr;""",
+ 'safe'
+ ),
+ # be aware that the following produces invalid code. You *have* to add
+ # a semicolon after a '}' followed by a normal instruction
+ (
+ 'missingSemicolon',
+ """\
+ var x = function() {
+
+ } /* missing ; here */
+ next_instr;
+ """,
+ """\
+ var x=function(){}next_instr;""",
+ 'full'
+ ),
+ (
+ 'missingSemicolon2',
+ """\
+ id=id || 'ids:list' // defaults to ids:list, this is the most common usage
+
+ if (selectbutton.isSelected==null){
+ initialState=initialState || false;
+ selectbutton.isSelected=initialState;
+ }
+ """,
+ """\
+ id=id||'ids:list'
+ if(selectbutton.isSelected==null){initialState=initialState||false;selectbutton.isSelected=initialState}
+ """,
+ 'safe'
+ ),
+ (
+ 'missingSemicolon2',
+ """\
+ id=id || 'ids:list' // defaults to ids:list, this is the most common usage
+
+ if (selectbutton.isSelected==null){
+ initialState=initialState || false;
+ selectbutton.isSelected=initialState;
+ }
+ """,
+ """\
+ id=id||'ids:list'
+ if(selectbutton.isSelected==null){initialState=initialState||false;selectbutton.isSelected=initialState}""",
+ 'full'
+ ),
+ # excessive semicolons after curly brackets get removed
+ (
+ 'nestedCurlyBracketsWithSemicolons',
+ """\
+ function dummy(a, b) {
+ if (a > b) {
+ do something
+ } else {
+ do something else
+ };
+ };
+ next_instr;
+ """,
+ """\
+ function dummy(a,b){if(a>b){do something} else{do something else}};next_instr;""",
+ 'safe'
+ ),
+ (
+ 'nestedCurlyBracketsWithSemicolons',
+ """\
+ function dummy(a, b) {
+ if (a > b) {
+ do something
+ } else {
+ do something else
+ };
+ };
+ next_instr;
+ """,
+ """\
+ function dummy(a,b){if(a>b){do something}else{do something else}};next_instr;""",
+ 'full'
+ ),
+ (
+ 'onelineVsMultilineComment',
+ """\
+ function abc() {
+ return value;
+ }; //********************
+
+ function xyz(a, b) {
+ /* docstring for this function */
+ if (a == null) {
+ return 1
+ }
+ }
+ """,
+ """\
+ function abc(){return value};
+ function xyz(a,b){if(a==null){return 1}}
+ """,
+ 'safe'
+ ),
+ (
+ 'onelineVsMultilineComment',
+ """\
+ function abc() {
+ return value;
+ }; //********************
+
+ function xyz(a, b) {
+ /* docstring for this function */
+ if (a == null) {
+ return 1
+ }
+ }
+ """,
+ """\
+ function abc(){return value};function xyz(a,b){if(a==null){return 1}}""",
+ 'full'
+ ),
+ (
+ 'conditionalIE',
+ """\
+ /* for Internet Explorer */
+ /*@cc_on @*/
+ /*@if (@_win32)
+ document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
+ var script = document.getElementById("__ie_onload");
+ script.onreadystatechange = function() {
+ if (this.readyState == "complete") {
+ DOMContentLoadedInit(); // call the onload handler
+ }
+ };
+ /*@end @*/
+ """,
+ """\
+ /*@cc_on @*/
+ /*@if (@_win32)
+ document.write("<script id=__ie_onload defer src=javascript:void(0)><\\/script>");var script=document.getElementById("__ie_onload");script.onreadystatechange=function(){if(this.readyState=="complete"){DOMContentLoadedInit()}};/*@end @*/
+ """
+ ),
+)
+
+
+css_safe_compression_tests = (
+ (
+ 'commentCompression',
+ """
+ /* this is a comment */
+ #testElement {
+ property: value; /* another comment */
+ }
+ /**********/
+ /* this is a multi
+ line comment */
+ #testElement {
+ /* yet another comment */
+ property: value;
+ }
+ """,
+ """\
+ /* */
+ #testElement {
+ property: value; /* */
+ }
+ /* */
+ #testElement {
+ /* */
+ property: value;
+ }
+ """
+ ),
+ (
+ 'newlineCompression',
+ """
+
+
+ /* this is a comment */
+
+ #testElement {
+ property: value; /* another comment */
+ }
+
+ /* this is a multi
+ line comment */
+ #testElement {
+
+ /* yet another comment */
+ property: value;
+
+ }
+
+
+ """,
+ """\
+ /* */
+ #testElement {
+ property: value; /* */
+ }
+ /* */
+ #testElement {
+ /* */
+ property: value;
+ }
+ """
+ ),
+ # see http://www.dithered.com/css_filters/index.html
+ (
+ 'commentHacks1',
+ """
+ #testElement {
+ property/**/: value;
+ property/* */: value;
+ property /**/: value;
+ property: /**/value;
+ }
+ """,
+ """\
+ #testElement {
+ property/**/: value;
+ property/* */: value;
+ property /**/: value;
+ property: /**/value;
+ }
+ """
+ ),
+ (
+ 'commentHacks2',
+ """
+ selector/* */ { }
+ """,
+ """\
+ selector/* */ { }
+ """
+ ),
+ (
+ 'commentHacks3',
+ """
+ selector/* foobar */ { }
+ """,
+ """\
+ selector/* */ { }
+ """
+ ),
+ (
+ 'commentHacks4',
+ """
+ selector/**/ { }
+ """,
+ """\
+ selector/**/ { }
+ """
+ ),
+ (
+ 'commentHacks5',
+ """
+ /* \*/
+ rules
+ /* */
+ """,
+ """\
+ /* \*/
+ rules
+ /* */
+ """
+ ),
+ (
+ 'commentHacks6',
+ """
+ /* foobar \*/
+ rules
+ /* */
+ """,
+ """\
+ /* \*/
+ rules
+ /* */
+ """
+ ),
+ (
+ 'commentHacks7',
+ """
+ /*/*/
+ rules
+ /* */
+ """,
+ """\
+ /*/*/
+ rules
+ /* */
+ """
+ ),
+ (
+ 'commentHacks8',
+ """
+ /*/*//*/
+ rules
+ /* */
+ """,
+ """\
+ /*/*//*/
+ rules
+ /* */
+ """
+ ),
+ (
+ 'stringProtection',
+ """
+ /* test string protection */
+ #selector,
+ #another {
+ content: 'foo; bar';
+ }
+ """,
+ """\
+ /* */
+ #selector,
+ #another {
+ content: 'foo; bar';
+ }
+ """
+ ),
+)
+
+css_full_compression_tests = (
+ (
+ 'commentCompression',
+ """
+ /* this is a comment */
+ #testElement {
+ property: value; /* another comment */
+ }
+ /**********/
+ /* this is a multi
+ line comment */
+ #testElement {
+ /* yet another comment */
+ property: value;
+ }
+ """,
+ """\
+ #testElement{property:value;}
+ #testElement{property:value;}
+ """
+ ),
+ (
+ 'newlineCompression',
+ """
+
+
+ /* this is a comment */
+
+ #testElement {
+ property: value; /* another comment */
+ }
+
+ /* this is a multi
+ line comment */
+ #testElement {
+
+ /* yet another comment */
+ property: value;
+
+ }
+
+
+ """,
+ """\
+ #testElement{property:value;}
+ #testElement{property:value;}
+ """
+ ),
+ # see http://www.dithered.com/css_filters/index.html
+ # in full compression all hacks get removed
+ (
+ 'commentHacks1',
+ """
+ #testElement {
+ property/**/: value;
+ property/* */: value;
+ property /**/: value;
+ property: /**/value;
+ }
+ """,
+ """\
+ #testElement{property:value;property:value;property:value;property:value;}
+ """
+ ),
+ (
+ 'commentHacks2',
+ """
+ selector/* */ { }
+ """,
+ """\
+ selector{}
+ """
+ ),
+ (
+ 'commentHacks3',
+ """
+ selector/* foobar */ { }
+ """,
+ """\
+ selector{}
+ """
+ ),
+ (
+ 'commentHacks4',
+ """
+ selector/**/ { }
+ """,
+ """\
+ selector{}
+ """
+ ),
+ (
+ 'commentHacks5',
+ """
+ /* \*/
+ rules
+ /* */
+ """,
+ """\
+ rules
+ """
+ ),
+ (
+ 'commentHacks6',
+ """
+ /* foobar \*/
+ rules
+ /* */
+ """,
+ """\
+ rules
+ """
+ ),
+ (
+ 'commentHacks7',
+ """
+ /*/*/
+ rules
+ /* */
+ """,
+ """\
+ rules
+ """
+ ),
+ (
+ 'commentHacks8',
+ """
+ /*/*//*/
+ rules
+ /* */
+ """,
+ """\
+ rules
+ """
+ ),
+ (
+ 'stringProtection',
+ """
+ /* test string protection and full compression */
+ #selector,
+ #another {
+ content: 'foo; bar';
+ }
+ """,
+ """\
+ #selector,#another{content:'foo; bar';}
+ """
+ ),
+)
+
+class PackerTestCase(unittest.TestCase):
+ def __init__(self, name, input, output, packer):
+ unittest.TestCase.__init__(self)
+ self.name = name
+ self.input = input
+ self.output = output
+ self.packer = packer
+
+ def __str__(self):
+ return self.name
+
+ def runTest(self):
+ self.assertEqual(self.packer.pack(self.input), self.output)
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+
+ jspacker = {
+ 'safe': JavascriptPacker('safe'),
+ 'full': JavascriptPacker('full'),
+ }
+ csspacker = {
+ 'safe': CSSPacker('safe'),
+ 'full': CSSPacker('full'),
+ }
+
+ for info in js_compression_tests:
+ name = info[0]
+ input = textwrap.dedent(info[1])
+ output = textwrap.dedent(info[2])
+ if (len(info) == 4):
+ compression = info[3].split(",")
+ else:
+ compression = ("safe", "full")
+
+ for packer in compression:
+ suite.addTest(PackerTestCase("%s (%s)" % (name, packer),
+ input, output,
+ jspacker[packer]))
+
+ packer = "safe"
+ for name, input, output in css_safe_compression_tests:
+ input = textwrap.dedent(input)
+ output = textwrap.dedent(output)
+
+ suite.addTest(PackerTestCase("%s (%s)" % (name, packer),
+ input, output,
+ csspacker[packer]))
+
+ packer = "full"
+ for name, input, output in css_full_compression_tests:
+ input = textwrap.dedent(input)
+ output = textwrap.dedent(output)
+
+ suite.addTest(PackerTestCase("%s (%s)" % (name, packer),
+ input, output,
+ csspacker[packer]))
+
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Modified: zope-resourceregistries/trunk/version.txt
===================================================================
--- zope-resourceregistries/trunk/version.txt 2007-02-09 14:46:00 UTC (rev 660)
+++ zope-resourceregistries/trunk/version.txt 2007-02-09 14:47:50 UTC (rev 661)
@@ -1 +1 @@
-1.3.2
+1.3.4
More information about the pkg-zope-commits
mailing list