[Checkins] SVN: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ Simplify test application and tests a bit. We can do this now because we don't support zope.app.testing anymore in the tests.
Brian Sutherland
jinty at web.de
Sun Jan 30 08:57:44 EST 2011
Log message for revision 120011:
Simplify test application and tests a bit. We can do this now because we don't support zope.app.testing anymore in the tests.
Changed:
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/README.txt
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/__init__.py
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/controls.html
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/forms.html
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/navigate.html
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/textarea.html
U zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/wsgitestapp.py
-=-
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/README.txt
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/README.txt 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/README.txt 2011-01-30 13:57:44 UTC (rev 120011)
@@ -1250,13 +1250,13 @@
Let's visit a page that echos some interesting values from it's request:
- >>> browser.open('http://localhost/@@echo.html')
+ >>> browser.open('http://localhost/echo.html')
>>> print browser.contents
HTTP_ACCEPT_LANGUAGE: en-US
HTTP_CONNECTION: close
HTTP_HOST: localhost
HTTP_USER_AGENT: Python-urllib/2.4
- PATH_INFO: /@@echo.html
+ PATH_INFO: /echo.html
REQUEST_METHOD: GET
Body: ''
@@ -1264,7 +1264,7 @@
and an optional content type. If we just pass a string, then
a URL-encoded query string is assumed:
- >>> browser.post('http://localhost/@@echo.html', 'x=1&y=2')
+ >>> browser.post('http://localhost/echo.html', 'x=1&y=2')
>>> print browser.contents
CONTENT_LENGTH: 7
CONTENT_TYPE: application/x-www-form-urlencoded
@@ -1272,7 +1272,7 @@
HTTP_CONNECTION: close
HTTP_HOST: localhost
HTTP_USER_AGENT: Python-urllib/2.4
- PATH_INFO: /@@echo.html
+ PATH_INFO: /echo.html
REQUEST_METHOD: POST
x: 1
y: 2
@@ -1282,7 +1282,7 @@
We can pass a content-type explicitly:
- >>> browser.post('http://localhost/@@echo.html',
+ >>> browser.post('http://localhost/echo.html',
... '{"x":1,"y":2}', 'application/x-javascript')
>>> print browser.contents
CONTENT_LENGTH: 13
@@ -1291,7 +1291,7 @@
HTTP_CONNECTION: close
HTTP_HOST: localhost
HTTP_USER_AGENT: Python-urllib/2.4
- PATH_INFO: /@@echo.html
+ PATH_INFO: /echo.html
REQUEST_METHOD: POST
Body: '{"x":1,"y":2}'
@@ -1342,8 +1342,7 @@
>>> browser.open('http://localhost/invalid')
Traceback (most recent call last):
...
- NotFound: Object: <zope.site.folder.Folder object at ...>,
- name: u'invalid'
+ NotFound: /invalid
NB: Setting the handleErrors attribute to False will only change
anything if the http server you're testing is using Zope 3's
@@ -1376,8 +1375,7 @@
>>> browser.open('http://localhost/invalid')
Traceback (most recent call last):
...
- NotFound: Object: <zope.site.folder.Folder object at ...>,
- name: u'invalid'
+ NotFound: /invalid
>>> browser.raiseHttpErrors = True
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/__init__.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/__init__.py 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/__init__.py 2011-01-30 13:57:44 UTC (rev 120011)
@@ -11,39 +11,3 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-
-class View:
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
-_interesting_environ = ('CONTENT_LENGTH',
- 'CONTENT_TYPE',
- 'HTTP_ACCEPT_LANGUAGE',
- 'HTTP_CONNECTION',
- 'HTTP_HOST',
- 'HTTP_USER_AGENT',
- 'PATH_INFO',
- 'REQUEST_METHOD')
-
-class Echo(View):
- """Simply echo the interesting parts of the request"""
-
- def __call__(self):
- items = []
- for k in _interesting_environ:
- v = self.request.get(k, None)
- if v is None:
- continue
- items.append('%s: %s' % (k, v))
- items.extend('%s: %s' % x for x in sorted(self.request.form.items()))
- items.append('Body: %r' % self.request.bodyStream.read())
- return '\n'.join(items)
-
-
-class EchoOne(View):
- """Echo one variable from the request"""
-
- def __call__(self):
- return repr(self.request.get(self.request.form['var']))
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/controls.html
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/controls.html 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/controls.html 2011-01-30 13:57:44 UTC (rev 120011)
@@ -7,32 +7,32 @@
<div>
<label for="text-value">Text Control</label>
- <em tal:condition="request/text-value|nothing"
- tal:content="request/text-value"></em>
+ <em tal:condition="request/params/text-value|nothing"
+ tal:content="request/params/text-value"></em>
<input type="text" name="text-value" id="text-value"
value="Some Text" />
</div>
<div>
<label for="password-value">Password Control</label>
- <em tal:condition="request/password-value|nothing"
- tal:content="request/password-value"></em>
+ <em tal:condition="request/params/password-value|nothing"
+ tal:content="request/params/password-value"></em>
<input type="password" name="password-value" id="password-value"
value="Password" />
</div>
<div>
<label for="hidden-value">Hidden Control</label> (label: hee hee)
- <em tal:condition="request/hidden-value|nothing"
- tal:content="request/hidden-value"></em>
+ <em tal:condition="request/params/hidden-value|nothing"
+ tal:content="request/params/hidden-value"></em>
<input type="hidden" name="hidden-value" id="hidden-value"
value="Hidden" />
</div>
<div>
<label for="textarea-value">Text Area Control</label>
- <em tal:condition="request/textarea-value|nothing"
- tal:content="request/textarea-value"></em>
+ <em tal:condition="request/params/textarea-value|nothing"
+ tal:content="request/params/textarea-value"></em>
<textarea name="textarea-value" id="textarea-value">
Text inside
area!
@@ -41,15 +41,15 @@
<div>
<label for="file-value">File Control</label>
- <em tal:condition="request/file-value|nothing"
- tal:content="request/file-value"></em>
+ <em tal:condition="request/params/file-value|nothing"
+ tal:content="request/params/file-value"></em>
<input type="file" name="file-value" id="file-value" />
</div>
<div>
<label for="single-select-value">Single Select Control</label>
- <em tal:condition="request/single-select-value|nothing"
- tal:content="request/single-select-value"></em>
+ <em tal:condition="request/params/single-select-value|nothing"
+ tal:content="request/params/single-select-value"></em>
<select name="single-select-value" id="single-select-value">
<option value="1">Uno</option>
<option value="2">Dos</option>
@@ -59,8 +59,8 @@
<div>
<label for="multi-select-value">Multiple Select Control</label>
- <em tal:condition="request/multi-select-value|nothing"
- tal:content="request/multi-select-value"></em>
+ <em tal:condition="request/params/multi-select-value|nothing"
+ tal:content="request/params/multi-select-value"></em>
<select name="multi-select-value" id="multi-select-value"
multiple="multiple">
<option value="1">Un</option>
@@ -70,8 +70,8 @@
</div>
<div>
- <em tal:condition="request/single-unvalued-checkbox-value|nothing"
- tal:content="request/single-unvalued-checkbox-value"></em>
+ <em tal:condition="request/params/single-unvalued-checkbox-value|nothing"
+ tal:content="request/params/single-unvalued-checkbox-value"></em>
<input type="checkbox" name="single-unvalued-checkbox-value"
id="single-unvalued-checkbox" checked="checked" />
<label for="single-unvalued-checkbox">Single Unvalued Checkbox</label>
@@ -79,8 +79,8 @@
<div>
<em tal:condition="
- request/single-disabled-unvalued-checkbox-value|nothing"
- tal:content="request/single-disabled-unvalued-checkbox-value"></em>
+ request/params/single-disabled-unvalued-checkbox-value|nothing"
+ tal:content="request/params/single-disabled-unvalued-checkbox-value"></em>
<input type="checkbox" name="single-disabled-unvalued-checkbox-value"
id="single-disabled-unvalued-checkbox" checked="checked"
disabled="disabled" />
@@ -90,8 +90,8 @@
</div>
<div>
- <em tal:condition="request/single-valued-checkbox-value|nothing"
- tal:content="request/single-valued-checkbox-value"></em>
+ <em tal:condition="request/params/single-valued-checkbox-value|nothing"
+ tal:content="request/params/single-valued-checkbox-value"></em>
<label><input type="checkbox" name="single-valued-checkbox-value"
value="1" checked="checked" />Single Valued Checkbox
</label>
@@ -99,8 +99,8 @@
<div>
(Multi checkbox: options have the labels)
- <em tal:condition="request/multi-checkbox-value|nothing"
- tal:content="request/multi-checkbox-value"></em>
+ <em tal:condition="request/params/multi-checkbox-value|nothing"
+ tal:content="request/params/multi-checkbox-value"></em>
<label><input type="checkbox" name="multi-checkbox-value" value="1"
checked="checked" /> One</label>
<input type="checkbox" name="multi-checkbox-value" value="2"
@@ -114,8 +114,8 @@
<div>
(Radio: options have the labels)
- <em tal:condition="request/radio-value|nothing"
- tal:content="request/radio-value"></em>
+ <em tal:condition="request/params/radio-value|nothing"
+ tal:content="request/params/radio-value"></em>
<label><input type="radio" name="radio-value" value="1" />Ein</label>
<input type="radio" name="radio-value" id="radio-value-2" value="2"
checked="checked" />
@@ -127,18 +127,18 @@
<div>
<label for="image-value">Image Control</label>
- <em tal:condition="request/image-value.x|nothing"
- tal:content="request/image-value.x"></em>
- <em tal:condition="request/image-value.y|nothing"
- tal:content="request/image-value.y"></em>
+ <em tal:condition="request/params/image-value.x|nothing"
+ tal:content="request/params/image-value.x"></em>
+ <em tal:condition="request/params/image-value.y|nothing"
+ tal:content="request/params/image-value.y"></em>
<input type="image" name="image-value" id="image-value"
src="zope3logo.gif" />
</div>
<div>
<label for="submit-value">Standard Submit Control</label>
- <em tal:condition="request/submit-value|nothing"
- tal:content="request/submit-value"></em>
+ <em tal:condition="request/params/submit-value|nothing"
+ tal:content="request/params/submit-value"></em>
<input type="submit" name="submit-value" id="submit-value"
value="Submit This" />
</div>
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/forms.html
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/forms.html 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/forms.html 2011-01-30 13:57:44 UTC (rev 120011)
@@ -3,8 +3,8 @@
<h1>Forms Tests</h1>
- <em tal:condition="request/text-value|nothing"
- tal:content="request/text-value" />
+ <em tal:condition="request/params/text-value|nothing"
+ tal:content="request/params/text-value" />
<form id="1" name="one" action="forms.html">
<input type="text" name="text-value" value="First Text" />
@@ -28,8 +28,8 @@
<label for="text-value-4">Text Control</label>
<input type="text" name="text-value" id="text-value-4"
value="Fourth Text" />
- <em tal:condition="python: 'hidden-4' in request.form and
- 'submit-4' not in request.form"
+ <em tal:condition="python: 'hidden-4' in request.params and
+ 'submit-4' not in request.params"
>Submitted without the submit button.</em>
<input type="submit" name="submit-4" value="Don't Submit Me" />
<input type="hidden" name="hidden-4" value="marker" />
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/navigate.html
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/navigate.html 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/navigate.html 2011-01-30 13:57:44 UTC (rev 120011)
@@ -3,8 +3,8 @@
<h1>Navigation Tests</h1>
- <p tal:condition="request/message|nothing">
- Message: <em tal:content="request/message">Message</em>
+ <p tal:condition="request/params/message|nothing">
+ Message: <em tal:content="request/params/message">Message</em>
</p>
<a href="navigate.html?message=By+Link+Text">Link Text</a>
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/textarea.html
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/textarea.html 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/textarea.html 2011-01-30 13:57:44 UTC (rev 120011)
@@ -6,8 +6,8 @@
<form action="textarea.html" method="post">
<div>
<label for="textarea-value">Text Area Control</label>
- <em tal:condition="request/textarea-value|nothing"
- tal:content="request/textarea-value"></em>
+ <em tal:condition="request/params/textarea-value|nothing"
+ tal:content="request/params/textarea-value"></em>
<textarea name="textarea-value" id="textarea-value"><block>
<feed/>
&
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/wsgitestapp.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/wsgitestapp.py 2011-01-30 13:47:36 UTC (rev 120010)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ftests/wsgitestapp.py 2011-01-30 13:57:44 UTC (rev 120011)
@@ -23,29 +23,8 @@
from zope.testbrowser import ftests
class NotFound(Exception):
+ pass
- def __init__(self, ob, name):
- self.ob = ob
- self.name = name
-
- def __str__(self):
- return 'Object: %s, name: %r' % (self.ob, self.name)
-
-
-class ZopeRequestAdapter(object):
- """Adapt a webob request into enough of a zope.publisher request for the tests to pass"""
-
- def __init__(self, request, response=None):
- self._request = request
- self._response = response
-
- @property
- def form(self):
- return self._request.params
-
- def __getitem__(self, name):
- return self._request.params[name]
-
_HERE = os.path.dirname(__file__)
class MyPageTemplateFile(PageTemplateFile):
@@ -61,7 +40,7 @@
def __call__(self, environ, start_response):
req = Request(environ)
handler = {'/set_status.html': set_status,
- '/@@echo.html': echo,
+ '/echo.html': echo,
'/echo_one.html': echo_one,
'/set_cookie.html': set_cookie,
'/get_cookie.html': get_cookie,
@@ -85,7 +64,7 @@
return resp(environ, start_response)
def handle_notfound(req):
- raise NotFound('<WSGI application>', unicode(req.path_info[1:]))
+ raise NotFound(req.path_info)
def handle_resource(req):
filename = req.path_info.split('/')[-1]
@@ -93,8 +72,7 @@
path = os.path.join(_HERE, filename)
if type == 'text/html':
pt = MyPageTemplateFile(path)
- zreq = ZopeRequestAdapter(req)
- contents = pt(zreq)
+ contents = pt(req)
else:
contents = open(path, 'r').read()
return Response(contents, content_type=type)
@@ -116,9 +94,18 @@
resp.set_cookie(name, value, **cookie_parms)
return resp
+_interesting_environ = ('CONTENT_LENGTH',
+ 'CONTENT_TYPE',
+ 'HTTP_ACCEPT_LANGUAGE',
+ 'HTTP_CONNECTION',
+ 'HTTP_HOST',
+ 'HTTP_USER_AGENT',
+ 'PATH_INFO',
+ 'REQUEST_METHOD')
+
def echo(req):
items = []
- for k in ftests._interesting_environ:
+ for k in _interesting_environ:
v = req.environ.get(k, None)
if v is None:
continue
More information about the checkins
mailing list