[CMF-checkins] CVS: Products/CMFCore/tests - test_PortalFolder.py:1.21.4.5

Stefan H. Holek stefan at epy.co.at
Tue Jul 20 08:43:32 EDT 2004


Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv9765/CMFCore/tests

Modified Files:
      Tag: CMF-1_4-branch
	test_PortalFolder.py 
Log Message:
CMFCore.PortalFolder: checkIdAvailable failed to catch zExceptions.BadRequest.


=== Products/CMFCore/tests/test_PortalFolder.py 1.21.4.4 => 1.21.4.5 ===
--- Products/CMFCore/tests/test_PortalFolder.py:1.21.4.4	Fri Apr 23 17:11:35 2004
+++ Products/CMFCore/tests/test_PortalFolder.py	Tue Jul 20 08:43:32 2004
@@ -24,6 +24,7 @@
 from Products.CMFCore.PortalFolder import ContentFilter
 from Products.CMFCore.interfaces.Dynamic import DynamicType as IDynamicType
 from webdav.WriteLockInterface import WriteLockInterface
+from zExceptions import BadRequest
 
 def extra_meta_types():
     return [  { 'name' : 'Dummy', 'action' : 'manage_addFolder' } ]
@@ -387,6 +388,27 @@
         assert not has_path( catalog._catalog, '/test/sub1/dummy' )
         assert has_path( catalog._catalog, '/test/sub2/dummy' )
         assert has_path( catalog._catalog, '/test/sub3/dummy' )
+
+    def test_setObjectRaisesBadRequest(self):
+        # _setObject() should raise zExceptions.BadRequest
+        # on duplicate id.
+        test = self.root.test
+        test._setObject('foo', DummyContent('foo'))
+        try:
+            test._setObject('foo', DummyContent('foo'))
+        except BadRequest:
+            pass
+        except:
+            # Zope < 2.7
+            e, v, tb = sys.exc_info(); del tb
+            if str(e) != 'Bad Request':
+                raise
+
+    def test_checkIdAvailableCatchesBadRequest(self):
+        # checkIdAvailable() should catch zExceptions.BadRequest
+        test = self.root.test
+        test._setObject('foo', DummyContent('foo'))
+        self.failIf(test.checkIdAvailable('foo'))
 
 class ContentFilterTests( TestCase ):
 



More information about the CMF-checkins mailing list