[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/tests/test_CatalogTool.py Style cleanup

Hanno Schlichting hannosch at hannosch.eu
Mon Aug 2 17:07:46 EDT 2010


Log message for revision 115390:
  Style cleanup
  

Changed:
  U   Products.CMFCore/trunk/Products/CMFCore/tests/test_CatalogTool.py

-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_CatalogTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_CatalogTool.py	2010-08-02 21:00:40 UTC (rev 115389)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_CatalogTool.py	2010-08-02 21:07:45 UTC (rev 115390)
@@ -11,29 +11,28 @@
 #
 ##############################################################################
 """ Unit tests for CatalogTool module.
-
-$Id$
 """
 
 import unittest
 
 from Acquisition import Implicit
 from zope.interface import implements
-from zope.component import getMultiAdapter
 from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.interfaces import IIndexableObject
 from Products.CMFCore.interfaces import IContentish
-
 from Products.CMFCore.tests.base.testcase import SecurityTest
 
+
 class FakeFolder(Implicit):
     id = 'portal'
 
+
 class FakeCatalog(Implicit):
     implements(ICatalogTool)
     id = 'portal_catalog'
 
+
 class FakeWorkflowTool(Implicit):
     id = 'portal_workflow'
 
@@ -43,6 +42,7 @@
     def getCatalogVariablesFor(self, ob):
         return self._vars
 
+
 class CatalogDummyContent(DummyContent):
 
     """ Dummy content that already provides IIndexableObject
@@ -52,6 +52,7 @@
     implements(IIndexableObject)
     allowedRolesAndUsers = ['Manager'] # default value
 
+
 class IndexableObjectWrapperTests(unittest.TestCase):
 
     def _getTargetClass(self):
@@ -104,7 +105,6 @@
         self.assertEqual(w.baz, 2)
 
     def test_provided(self):
-        from Products.CMFCore.interfaces import IContentish
         from Products.CMFCore.interfaces import IIndexableObjectWrapper
         from Products.CMFCore.interfaces import IIndexableObject
 
@@ -116,13 +116,13 @@
 
     def test_adapts(self):
         from zope.component import adaptedBy
-        from Products.CMFCore.interfaces import IContentish
         from Products.CMFCore.interfaces import ICatalogTool
 
         w = self._getTargetClass()
-        adapts =  adaptedBy(w) 
+        adapts = adaptedBy(w)
         self.assertEqual(adapts, (IContentish, ICatalogTool))
 
+
 class CatalogToolTests(SecurityTest):
 
     def _getTargetClass(self):
@@ -174,8 +174,8 @@
         tool.addIndex('SearchableText', 'KeywordIndex')
         dummy = self._makeContent(catalog=1)
 
-        tool.catalog_object( dummy, '/dummy' )
-        tool.catalog_object( dummy, '/dummy', [ 'SearchableText' ] )
+        tool.catalog_object(dummy, '/dummy')
+        tool.catalog_object(dummy, '/dummy', ['SearchableText'])
 
     def test_search_anonymous(self):
         catalog = self._makeOne()
@@ -190,7 +190,7 @@
         catalog = self._makeOne()
         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
         catalog.catalog_object(dummy, '/dummy')
 
         self.loginWithRoles('Blob')
@@ -202,7 +202,7 @@
         catalog = self._makeOne()
         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
         catalog.catalog_object(dummy, '/dummy')
 
         self.loginWithRoles('Blob')
@@ -215,7 +215,7 @@
         catalog = self._makeOne()
         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRoleAndUsers = ('Blob',)
+        dummy.allowedRoleAndUsers = ('Blob', )
         catalog.catalog_object(dummy, '/dummy')
 
         self.loginWithRoles('Waggle')
@@ -227,7 +227,7 @@
         catalog = self._makeOne()
         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
         catalog.catalog_object(dummy, '/dummy')
 
         self.loginWithRoles('Waggle')
@@ -244,7 +244,7 @@
         catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
 
         self.loginWithRoles('Blob')
 
@@ -305,7 +305,7 @@
         catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
 
         self.loginWithRoles('Blob')
 
@@ -339,7 +339,7 @@
         catalog.addIndex('expires', 'DateIndex')
         now = DateTime()
         dummy = self._makeContent(catalog=1)
-        dummy.allowedRolesAndUsers = ('Blob',)
+        dummy.allowedRolesAndUsers = ('Blob', )
 
         self.loginWithRoles('Blob')
 
@@ -434,9 +434,10 @@
         convert(kw)
         self.assertEqual(kw, {'expires': {'query': 5, 'range': 'max'}})
 
-        kw = {'expires': (5,7), 'expires_usage': 'range:min:max'}
+        kw = {'expires': (5, 7), 'expires_usage': 'range:min:max'}
         convert(kw)
-        self.assertEqual(kw, {'expires': {'query': (5,7), 'range': 'min:max'}})
+        self.assertEqual(kw, {'expires':
+                              {'query': (5, 7), 'range': 'min:max'}})
 
     def test_refreshCatalog(self):
         from Products.CMFCore.tests.base.dummy import DummySite
@@ -451,7 +452,7 @@
         self.assertEqual(1, len(ctool._catalog.searchResults()),
                          'CMF Collector issue #379 (\'Update Catalog\' '
                          'fails): %s entries after refreshCatalog'
-                         % (len(ctool._catalog.searchResults()),))
+                         % (len(ctool._catalog.searchResults()), ))
 
     def test_listAllowedRolesAndUsers_proxyroles(self):
         # https://bugs.launchpad.net/zope-cmf/+bug/161729
@@ -476,14 +477,14 @@
         self.failUnless('user:%s' % user.getId() in arus)
 
         # Third case, proxy roles are an empty tuple. This happens if
-        # proxy roles are unset using the ZMI. The behavior should 
+        # proxy roles are unset using the ZMI. The behavior should
         # mirror the first case with no proxy role setting at all.
         self.setupProxyRoles()
         arus = catalog._listAllowedRolesAndUsers(user)
         self.assertEquals(len(arus), 3)
         self.failUnless('Anonymous' in arus)
         self.failUnless('Blob' in arus)
-        self.failUnless('user:%s' % user.getId() in arus)       
+        self.failUnless('user:%s' % user.getId() in arus)
 
     def test_wrapping1(self):
         # DummyContent implements IIndexableObject
@@ -511,20 +512,18 @@
 
         from zope.component import getSiteManager
         self.sm = getSiteManager()
-        self.sm.registerAdapter( FakeWrapper
-                               , (IContentish, ICatalogTool)
-                               , IIndexableObject )
+        self.sm.registerAdapter(FakeWrapper,
+                                (IContentish, ICatalogTool),
+                                IIndexableObject)
 
         dummy =DummyContent(catalog=1)
         ctool = self._makeOne()
         ctool.catalog_object(dummy, '/dummy')
         self.assertEqual(1, len(ctool._catalog.searchResults()))
 
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(IndexableObjectWrapperTests),
         unittest.makeSuite(CatalogToolTests),
         ))
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')



More information about the checkins mailing list