[Checkins] SVN: zope.testbrowser/branches/jinty-webtest2/s * Implement a small test for the code specific to the Zope

Brian Sutherland jinty at web.de
Tue Jan 18 20:24:00 EST 2011


Log message for revision 119678:
  * Implement a small test for the code specific to the Zope
    Publisher Browser
  * Stop using the Zope Publisher to run all the tests
  * Simplify the Zope Publisher test application (removing the
    zope.browserresource dependency)
  

Changed:
  U   zope.testbrowser/branches/jinty-webtest2/setup.py
  U   zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/__init__.py
  U   zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/ftesting.zcml
  U   zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/tests.py
  A   zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/zope-publisher.txt

-=-
Modified: zope.testbrowser/branches/jinty-webtest2/setup.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest2/setup.py	2011-01-19 00:23:13 UTC (rev 119677)
+++ zope.testbrowser/branches/jinty-webtest2/setup.py	2011-01-19 01:24:00 UTC (rev 119678)
@@ -59,7 +59,6 @@
         'test': [
             'WebTest',
             'zope.browserpage',
-            'zope.browserresource',
             'zope.component',
             'zope.container',
             'zope.principalregistry',

Modified: zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/__init__.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/__init__.py	2011-01-19 00:23:13 UTC (rev 119677)
+++ zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/__init__.py	2011-01-19 01:24:00 UTC (rev 119678)
@@ -47,31 +47,3 @@
 
     def __call__(self):
         return repr(self.request.get(self.request.form['var']))
-
-
-class GetCookie(View):
-    """Gets cookie value"""
-
-    def __call__(self):
-        return '\n'.join(
-            ('%s: %s' % (k, v)) for k, v in sorted(
-                self.request.cookies.items()))
-
-class SetCookie(View):
-    """Sets cookie value"""
-
-    def __call__(self):
-        self.request.response.setCookie(
-            **dict((str(k), str(v)) for k, v in self.request.form.items()))
-
-
-class SetStatus(View):
-    """Sets HTTP status"""
-
-    def __call__(self):
-        status = self.request.get('status')
-        if status:
-            self.request.response.setStatus(int(status))
-            return 'Just set a status of %s' % status
-        else:
-            return 'Everything fine'

Modified: zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/ftesting.zcml
===================================================================
--- zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/ftesting.zcml	2011-01-19 00:23:13 UTC (rev 119677)
+++ zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/ftests/ftesting.zcml	2011-01-19 01:24:00 UTC (rev 119678)
@@ -8,12 +8,10 @@
   <!-- This file is used for functional testing setup -->
 
   <include package="zope.browserpage" file="meta.zcml" />
-  <include package="zope.browserresource" file="meta.zcml" />
   <include package="zope.component" file="meta.zcml" />
   <include package="zope.security" file="meta.zcml" />
   <include package="zope.app.publication" file="meta.zcml" />
 
-  <include package="zope.browserresource" />
   <include package="zope.container" />
   <include package="zope.principalregistry" />
   <include package="zope.ptresource" />
@@ -42,29 +40,4 @@
      permission="zope.Public"
      />
 
-  <browser:page
-     name="set_cookie.html"
-     for="*"
-     class=".ftests.SetCookie"
-     permission="zope.Public"
-     />
-
-  <browser:page
-     name="get_cookie.html"
-     for="*"
-     class=".ftests.GetCookie"
-     permission="zope.Public"
-     />
-
-  <browser:page
-     name="set_status.html"
-     for="*"
-     class=".ftests.SetStatus"
-     permission="zope.Public"
-     />
-
-  <browser:resourceDirectory
-      name="testbrowser"
-      directory="ftests" />
-
 </configure>

Modified: zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/tests.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/tests.py	2011-01-19 00:23:13 UTC (rev 119677)
+++ zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/tests.py	2011-01-19 01:24:00 UTC (rev 119678)
@@ -484,31 +484,14 @@
 
     tests = [this_file, wire]
 
-    # test using the connection to the zope3 functional testing suite
-    globals = dict(Browser=TestingBrowser)
+    # Zope Publisher Tests
+    zope_publisher = FunctionalDocFileSuite('zope-publisher.txt', optionflags=flags,
+        checker=checker)
+    zope_publisher.layer = TestBrowserLayer
 
-    readme = FunctionalDocFileSuite('README.txt', optionflags=flags,
-        checker=checker, globs=globals)
-    readme.layer = TestBrowserLayer
+    tests.append(zope_publisher)
 
-    def setUp(test):
-        folder = test.globs['getRootFolder']()
-        import zope.site.folder
-        folder['inner'] = zope.site.folder.Folder()
-        folder['inner']['path'] = zope.site.folder.Folder()
-        import transaction
-        transaction.commit()
-    cookies = FunctionalDocFileSuite('cookies.txt', optionflags=flags,
-        checker=checker, globs=globals, setUp=setUp)
-    cookies.layer = TestBrowserLayer
-
-    fixed_bugs = FunctionalDocFileSuite('fixed-bugs.txt', optionflags=flags,
-        globs=globals)
-    fixed_bugs.layer = TestBrowserLayer
-
-    tests.extend([readme, cookies, fixed_bugs])
-
-    # re-run the above tests using the WSGI connectior
+    # WSGI Browser tests
     def make_browser(*args, **kw):
         app = WSGITestApplication()
         test_app = TestApp(app)

Added: zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/zope-publisher.txt
===================================================================
--- zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/zope-publisher.txt	                        (rev 0)
+++ zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/zope-publisher.txt	2011-01-19 01:24:00 UTC (rev 119678)
@@ -0,0 +1,81 @@
+Zope Publisher Browser Tests
+============================
+
+These tests specifically test the implementation of Browser which uses the Zope
+Publisher via zope.app.testing as the application to test.
+
+    >>> from zope.testbrowser.testing import Browser
+    >>> browser = Browser()
+
+Error Handling
+--------------
+
+handleErrors works as advertised:
+    
+    >>> browser.handleErrors
+    True
+    >>> browser.open('http://localhost/invalid')
+    Traceback (most recent call last):
+    ...
+    HTTPError: HTTP Error 404: Not Found
+
+So when we tell the publisher not to handle the errors,
+
+    >>> browser.handleErrors = False
+    >>> browser.open('http://localhost/invalid')
+    Traceback (most recent call last):
+    ...
+    NotFound: Object: <zope.site.folder.Folder object at ...>,
+              name: u'invalid'
+
+Spaces in URLs
+--------------
+
+Spaces in URLs don't cause blowups:
+
+    >>> browser.open('http://localhost/space here')
+    Traceback (most recent call last):
+    ...
+    NotFound: Object: <zope.site.folder.Folder object at ...>,
+              name: u'space here'
+
+Headers
+-------
+
+Sending arbitrary headers works:
+
+    >>> browser.addHeader('Accept-Language', 'en-US')
+    >>> browser.open('http://localhost/echo_one.html?var=HTTP_ACCEPT_LANGUAGE')
+    >>> print browser.contents
+    'en-US'
+
+POST
+----
+
+HTTP posts are correctly sent:
+
+    >>> browser.post('http://localhost/echo.html', 'x=1&y=2')
+    >>> print browser.contents
+    CONTENT_LENGTH: 7
+    CONTENT_TYPE: application/x-www-form-urlencoded
+    HTTP_ACCEPT_LANGUAGE: en-US
+    HTTP_CONNECTION: close
+    HTTP_HOST: localhost
+    HTTP_USER_AGENT: Python-urllib/2.4
+    PATH_INFO: /echo.html
+    REQUEST_METHOD: POST
+    x: 1
+    y: 2
+    Body: ''
+    
+Returned headers
+----------------
+
+Server headers are correctly returned:
+
+    >>> print browser.headers
+    Status: 200 OK
+    Content-Length: 123
+    Content-Type: text/plain;charset=utf-8
+    X-Content-Type-Warning: guessed from content
+    X-Powered-By: Zope (www.zope.org), Python (www.python.org)


Property changes on: zope.testbrowser/branches/jinty-webtest2/src/zope/testbrowser/zope-publisher.txt
___________________________________________________________________
Added: svn:eol-style
   + native



More information about the checkins mailing list