[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/tests/ - fix DocResponseWrapper.getBody()

Fred L. Drake, Jr. fdrake at gmail.com
Thu Sep 9 15:03:03 EDT 2004


Log message for revision 27483:
  - fix DocResponseWrapper.getBody()
  - add unit tests for DocResponseWrapper
  


Changed:
  U   Zope3/trunk/src/zope/app/tests/functional.py
  A   Zope3/trunk/src/zope/app/tests/test_functional.py


-=-
Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py	2004-09-09 18:22:48 UTC (rev 27482)
+++ Zope3/trunk/src/zope/app/tests/functional.py	2004-09-09 19:03:03 UTC (rev 27483)
@@ -454,6 +454,9 @@
             return "%s\n\n%s" % (self.header_output, body)
         return "%s\n" % (self.header_output)
 
+    def getBody(self):
+        return self.getOutput()
+
 def http(request_string, handle_errors=True):
     """Execute an HTTP request string via the publisher
 

Added: Zope3/trunk/src/zope/app/tests/test_functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test_functional.py	2004-09-09 18:22:48 UTC (rev 27482)
+++ Zope3/trunk/src/zope/app/tests/test_functional.py	2004-09-09 19:03:03 UTC (rev 27483)
@@ -0,0 +1,60 @@
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+"""Tests for zope.app.tests.functional."""
+
+import StringIO
+import unittest
+
+import zope.app.tests.functional
+
+
+HEADERS = """\
+HTTP/1.1 200 Ok
+Content-Type: text/plain
+"""
+
+BODY = """\
+This is the response body.
+"""
+
+class DocResponseWrapperTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.body_output = StringIO.StringIO()
+        self.path = "/foo/bar/"
+        self.response = object()
+
+        self.wrapper = zope.app.tests.functional.DocResponseWrapper(
+            self.response, self.body_output, self.path, HEADERS)
+
+    def test__str__(self):
+        self.assertEqual(str(self.wrapper),
+                         HEADERS + "\n")
+        self.body_output.write(BODY)
+        self.assertEqual(str(self.wrapper),
+                         "%s\n\n%s" % (HEADERS, BODY))
+
+    def test_getBody(self):
+        self.assertEqual(self.wrapper.getBody(), "")
+        self.body_output.write(BODY)
+        self.assertEqual(self.wrapper.getBody(), BODY)
+
+    def test_getOutput(self):
+        self.assertEqual(self.wrapper.getOutput(), "")
+        self.body_output.write(BODY)
+        self.assertEqual(self.wrapper.getOutput(), BODY)
+
+
+def test_suite():
+    return unittest.makeSuite(DocResponseWrapperTestCase)


Property changes on: Zope3/trunk/src/zope/app/tests/test_functional.py
___________________________________________________________________
Name: svn:mime-type
   + text/x-python
Name: svn:eol-style
   + native



More information about the Zope3-Checkins mailing list