[Zope3-checkins] SVN: Zope3/branches/ctheune-issue-125/src/zope/app/http/ added functional test for HTTP PUT

Wolfgang Schnerring wosc at wosc.de
Thu Sep 28 04:16:43 EDT 2006


Log message for revision 70411:
  added functional test for HTTP PUT

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

-=-
Added: Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/__init__.py
===================================================================
--- Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/__init__.py	2006-09-28 07:30:15 UTC (rev 70410)
+++ Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/__init__.py	2006-09-28 08:16:37 UTC (rev 70411)
@@ -0,0 +1 @@
+# python package

Added: Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/test_put.py
===================================================================
--- Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/test_put.py	2006-09-28 07:30:15 UTC (rev 70410)
+++ Zope3/branches/ctheune-issue-125/src/zope/app/http/ftests/test_put.py	2006-09-28 08:16:37 UTC (rev 70411)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test HTTP PUT verb
+
+$Id: test_put.py 67630 2006-04-27 00:54:03Z jim $
+"""
+
+from unittest import TestSuite, makeSuite
+
+from zope.app.testing.functional import FunctionalTestCase, HTTPCaller
+
+class TestPUT(FunctionalTestCase):
+    def test_put(self):
+        # PUT something for the first time
+        response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
+Authorization: Basic bWdyOm1ncnB3
+Content-Length: 20
+Content-Type: text/plain
+
+This is just a test.""")
+        self.assertEquals(response._response.getStatus(), 201)
+        self.assertEquals(response._response.getHeader("Location"),
+                          "http://localhost/testfile.txt")
+
+        response = HTTPCaller()(r"""GET /testfile.txt HTTP/1.1
+Authorization: Basic bWdyOm1ncnB3""")
+        self.assertEquals(response.getBody(), "This is just a test.")
+
+        # now modify it
+        response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
+Authorization: Basic bWdyOm1ncnB3
+Content-Length: 22
+Content-Type: text/plain
+
+And now it is modified.""")
+        self.assertEquals(response._response.getStatus(), 200)
+        self.assertEquals(response.getBody(), "")
+
+        response = HTTPCaller()(r"""GET /testfile.txt HTTP/1.1
+Authorization: Basic bWdyOm1ncnB3""")
+        self.assertEquals(response.getBody(), "And now it is modified.")
+        
+        
+def test_suite():
+    return TestSuite((
+        makeSuite(TestPUT),
+        ))

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:30:15 UTC (rev 70410)
+++ Zope3/branches/ctheune-issue-125/src/zope/app/http/put.py	2006-09-28 08:16:37 UTC (rev 70411)
@@ -114,4 +114,5 @@
         while chunk:
             adapter.write(chunk)
             chunk = body.read(2**6)
+
         return ''



More information about the Zope3-Checkins mailing list