[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/AddableService/tests - testAddable.py:1.1.2.4

Jim Fulton jim@zope.com
Sat, 8 Jun 2002 13:14:56 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/AddableService/tests
In directory cvs.zope.org:/tmp/cvs-serv32437/lib/python/Zope/App/OFS/Services/AddableService/tests

Modified Files:
      Tag: Zope-3x-branch
	testAddable.py 
Log Message:
Refactored isAddable method out of IContainer into a separate, more
specilized interface. This part of the framework needs more thought,
but, in any case, containers that don't need to restrict their content
(or that restrict it in other ways) shouldn't be burdened by this part
of the interface.

I also rewrote IContainer doc strings to conform to coding style.


=== Zope3/lib/python/Zope/App/OFS/Services/AddableService/tests/testAddable.py 1.1.2.3 => 1.1.2.4 ===
         self.assertEqual(getAddableContent(None), [])
 
-        getService(None, 'AddableContent').provideAddable('Contact', 'Personal Contact',
-                                        'blah\nblah')
+        getService(None, 'AddableContent').provideAddable(
+            'Contact', 'Personal Contact',
+            'blah\nblah')
 
         # you must provide a matching factory for the addable to be returned
         self.assertEqual(getAddableContent(None), [])
@@ -116,10 +117,15 @@
             pass
         from Zope.App.OFS.Content.Folder.Folder import Folder
         from Zope.ContextWrapper import Wrapper
+        from Zope.App.OFS.Container.IContainer import IHomogenousContainer
+
         class DummyFolder(Folder):
-            __implements__=Folder.__implements__, (IZ,)
+            __implements__=Folder.__implements__, IZ, IHomogenousContainer
+
             def isAddable(self, interfaces):
                 return membership_check(IB, interfaces)
+
+
         self.folder3=DummyFolder()
         self.rootFolder.setObject("folder3",self.folder3)
         self.folder3=Wrapper(self.folder3, self.rootFolder, name="folder3")
@@ -128,15 +134,25 @@
         provideFactory=getService(None, 'Factories').provideFactory
         provideAddable=getService(None, 'AddableServices').provideAddable
         provideFactory('A', fA)
-        provideAddable('A', 'Dummy A', 'Desc A', IX) # should be available in 1 and 1_1 (for_container)
+
+        # should be available in 1 and 1_1 (for_container)
+        provideAddable('A', 'Dummy A', 'Desc A', IX)
         provideFactory('B', fB)
-        provideAddable('B', 'Dummy B', 'Desc B', (IX1, IZ)) # should be in 1 and 3 (for_container)
+
+        # should be in 1 and 3 (for_container)
+        provideAddable('B', 'Dummy B', 'Desc B', (IX1, IZ))
         provideFactory('C', fC)
-        provideAddable('C', 'DummyC', 'Desc C', IX1) # should be in 1 (for_container)
+
+        # should be in 1 (for_container)
+        provideAddable('C', 'DummyC', 'Desc C', IX1)
         provideFactory('D', fD)
-        provideAddable('D', 'Dummy D', 'Desc D') # should be in ALL
+
+        # should be in ALLOW
+        provideAddable('D', 'Dummy D', 'Desc D')
         provideFactory('E', fE)
-        provideAddable('E', 'Dummy E', 'Desc E') # should be in 1 and 1_1 (isAddable)
+
+        # should be in 1 and 1_1
+        provideAddable('E', 'Dummy E', 'Desc E')
         AAd=Addable('A', 'Dummy A', 'Desc A', IX)
         BAd=Addable('B', 'Dummy B', 'Desc B', (IX1, IZ))
         CAd=Addable('C', 'DummyC', 'Desc C', IX1)
@@ -144,8 +160,10 @@
         EAd=Addable('E', 'Dummy E', 'Desc E')
         
         # and test!
+
+        # sort for more robust test
         self.assertEqual(getAddableServices(self.folder1),
-                         [AAd, BAd, CAd, DAd, EAd]) # sort for more robust test
+                         [AAd, BAd, CAd, DAd, EAd])
         self.assertEqual(getAddableServices(self.folder1_1),
                          [AAd, DAd, EAd]) # sort
         self.assertEqual(getAddableServices(self.folder3),
@@ -158,7 +176,8 @@
     def testAddable(self):
         myAddable=Addable('Contact', 'Personal Contact',
                                         'blah\nblah')
-        self.assertRaises(AttributeError, self.setAValue, myAddable, 'AnotherId')
+        self.assertRaises(AttributeError,
+                          self.setAValue, myAddable, 'AnotherId')
 
 def test_suite():
     loader=unittest.TestLoader()