[Zope3-checkins] SVN: Zope3/branches/ctheune-issue-125/src/zope/app/http/ made unit test for PUT work by using PlacefulSetup, so the Location-Header can be tested properly

Wolfgang Schnerring wosc at wosc.de
Thu Sep 28 03:19:28 EDT 2006


Log message for revision 70407:
  made unit test for PUT work by using PlacefulSetup, so the Location-Header can be tested properly

Changed:
  U   Zope3/branches/ctheune-issue-125/src/zope/app/http/put.py
  U   Zope3/branches/ctheune-issue-125/src/zope/app/http/tests/test_put.py

-=-
Modified: Zope3/branches/ctheune-issue-125/src/zope/app/http/put.py
===================================================================
--- Zope3/branches/ctheune-issue-125/src/zope/app/http/put.py	2006-09-28 07:10:02 UTC (rev 70406)
+++ Zope3/branches/ctheune-issue-125/src/zope/app/http/put.py	2006-09-28 07:19:28 UTC (rev 70407)
@@ -86,7 +86,6 @@
         dir_write[name] = newfile
         # Ickyness with non-predictable support for containment: 
         #   make sure we get a containment proxy
-        import pdb; pdb.set_trace() 
         newfile = dir_read[name]
 
         request.response.setStatus(201)

Modified: Zope3/branches/ctheune-issue-125/src/zope/app/http/tests/test_put.py
===================================================================
--- Zope3/branches/ctheune-issue-125/src/zope/app/http/tests/test_put.py	2006-09-28 07:10:02 UTC (rev 70406)
+++ Zope3/branches/ctheune-issue-125/src/zope/app/http/tests/test_put.py	2006-09-28 07:19:28 UTC (rev 70407)
@@ -21,10 +21,12 @@
 from zope.interface import implements
 from zope.publisher.browser import TestRequest
 from zope.filerepresentation.interfaces import IWriteFile
-from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
+from zope.filerepresentation.interfaces import IWriteDirectory, IReadDirectory, IFileFactory
 
 import zope.app.http.put
 from zope.app.testing.placelesssetup import PlacelessSetup
+from zope.app.component.testing import PlacefulSetup, Place
+from zope.location.interfaces import ILocation
 
 class File(object):
 
@@ -38,21 +40,30 @@
     def write(self, data):
         self.data = data
 
-class Container(object):
+class Container(Place):
 
-    implements(IWriteDirectory, IFileFactory)
+    implements(IWriteDirectory, IReadDirectory, IFileFactory, ILocation)
 
+    __name__ = None
+    __parent__ = None
+
     def __setitem__(self, name, object):
+        object.__name__ = name
+        object.__parent__ = self
         setattr(self, name, object)
 
+    def __getitem__(self, name):
+        return getattr(self, name)
+
     def __call__(self, name, content_type, data):
         return File(name, content_type, data)
 
 
-class TestNullPUT(PlacelessSetup, TestCase):
+class TestNullPUT(PlacefulSetup, TestCase):
 
     def test(self):
-        container = Container()
+        container = Container("put")
+        self.rootFolder["put"] = container
         content = "some content\n for testing"
         request = TestRequest(StringIO(content),
                               {'CONTENT_TYPE': 'test/foo',
@@ -71,13 +82,16 @@
 
         # Check HTTP Response
         self.assertEqual(request.response.getStatus(), 201)
+        self.assertEqual(request.response.getHeader("Location"),
+                         "http://127.0.0.1/put/spam")
 
     def test_bad_content_header(self):
         ## The previous behavour of the PUT method was to fail if the request
         ## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
         ## This was breaking the new Twisted server, so I am now allowing this
         ## this type of request to be valid.
-        container = Container()
+        container = Container("/put")
+        self.rootFolder["put"] = container
         content = "some content\n for testing"
         request = TestRequest(StringIO(content),
                               {'CONTENT_TYPE': 'test/foo',



More information about the Zope3-Checkins mailing list