[Checkins] SVN: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/ Rewrite functional tests to use zope.app.wsgi instead of zope.app.testing
Sylvain Viollon
sylvain at infrae.com
Tue Apr 13 10:27:23 EDT 2010
Log message for revision 110798:
Rewrite functional tests to use zope.app.wsgi instead of zope.app.testing
Changed:
U zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/ftesting.zcml
U zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/httpfactory.txt
U zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/methodnotallowed.txt
U zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/testing.py
U zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/tests/test_functional.py
-=-
Modified: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/ftesting.zcml
===================================================================
--- zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/ftesting.zcml 2010-04-13 14:23:56 UTC (rev 110797)
+++ zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/ftesting.zcml 2010-04-13 14:27:23 UTC (rev 110798)
@@ -2,8 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta"
i18n_domain="zope"
- package="zope.app.publication"
- >
+ package="zope.app.publication">
<!-- This file is the equivalent of site.zcml and it is -->
<!-- used for functional testing setup -->
Modified: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/httpfactory.txt
===================================================================
--- zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/httpfactory.txt 2010-04-13 14:23:56 UTC (rev 110797)
+++ zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/httpfactory.txt 2010-04-13 14:27:23 UTC (rev 110798)
@@ -10,24 +10,29 @@
A regular GET, POST or HEAD
+ >>> from zope.app.wsgi.testlayer import http
+
>>> print http(r"""
... GET / HTTP/1.1
... """)
- HTTP/1.1 200 OK
+ HTTP/1.0 200 OK
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: 4322
Content-Type: text/html;charset=utf-8
...
>>> print http(r"""
... POST / HTTP/1.1
... """)
- HTTP/1.1 200 OK
+ HTTP/1.0 200 OK
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: 4322
Content-Type: text/html;charset=utf-8
...
>>> print http(r"""
... HEAD / HTTP/1.1
... """)
- HTTP/1.1 200 OK
+ HTTP/1.0 200 OK
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: 0
Content-Type: text/html;charset=utf-8
<BLANKLINE>
@@ -39,6 +44,7 @@
... Content-Type: text/xml
... """)
HTTP/1.0 200 OK
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: ...
Content-Type: text/xml;charset=utf-8
...
@@ -54,6 +60,7 @@
... HTTP_SOAPACTION: soap#action
... """)
HTTP/1.0 200 OK
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Content-Length: ...
Content-Type: text/xml;charset=utf-8
...
Modified: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/methodnotallowed.txt
===================================================================
--- zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/methodnotallowed.txt 2010-04-13 14:23:56 UTC (rev 110797)
+++ zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/methodnotallowed.txt 2010-04-13 14:27:23 UTC (rev 110798)
@@ -4,22 +4,26 @@
If we get a request with a method that does not have a corresponding
view, HTTP 405 Method Not Allowed response is returned:
+ >>> from zope.app.wsgi.testlayer import http
+
>>> print http(r"""
... FROG / HTTP/1.1
... """)
- HTTP/1.1 405 Method Not Allowed
+ HTTP/1.0 405 Method Not Allowed
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
+ Content-Length: 18
Allow: DELETE, OPTIONS, PUT
- Content-Length: 18
<BLANKLINE>
Method Not Allowed
>>> print http(r"""
... DELETE / HTTP/1.1
- ... Authorization: Basic mgr:mgrpw
+ ... Authorization: Basic bWdyOm1ncnB3
... """)
- HTTP/1.1 405 Method Not Allowed
+ HTTP/1.0 405 Method Not Allowed
...
+
The request below should return 405, but instead crashes with a TypeError,
when the view tries to adapt context to IWriteFile.
Modified: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/testing.py
===================================================================
--- zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/testing.py 2010-04-13 14:23:56 UTC (rev 110797)
+++ zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/testing.py 2010-04-13 14:27:23 UTC (rev 110798)
@@ -18,8 +18,8 @@
__docformat__ = "reStructuredText"
-from zope.component.testlayer import ZCMLFileLayer
+from zope.app.wsgi.testlayer import BrowserLayer
import zope.app.publication
-PublicationLayer = ZCMLFileLayer(zope.app.publication, name='PublicationLayer')
+PublicationLayer = BrowserLayer(zope.app.publication, name='PublicationLayer')
Modified: zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/tests/test_functional.py
===================================================================
--- zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/tests/test_functional.py 2010-04-13 14:23:56 UTC (rev 110797)
+++ zope.app.publication/branches/sylvain-testlayers/src/zope/app/publication/tests/test_functional.py 2010-04-13 14:27:23 UTC (rev 110798)
@@ -28,16 +28,20 @@
(re.compile(r"HTTP/1\.([01]) (\d\d\d) .*"), r"HTTP/1.\1 \2 <MESSAGE>"),
])
+optionflags = doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE
def test_suite():
methodnotallowed = doctest.DocFileSuite(
- '../methodnotallowed.txt')
+ '../methodnotallowed.txt',
+ optionflags=optionflags)
methodnotallowed.layer = PublicationLayer
httpfactory = doctest.DocFileSuite(
- '../httpfactory.txt', checker=checker)
+ '../httpfactory.txt', checker=checker,
+ optionflags=optionflags)
httpfactory.layer = PublicationLayer
site = doctest.DocFileSuite(
- '../site.txt')
+ '../site.txt',
+ optionflags=optionflags)
site.layer = PublicationLayer
return unittest.TestSuite((
methodnotallowed,
More information about the checkins
mailing list