[Checkins] SVN: zope.app.http/trunk/s Clean zope.app.testing from tests.
Martijn Faassen
faassen at startifact.com
Wed Apr 14 10:05:18 EDT 2010
Log message for revision 110890:
Clean zope.app.testing from tests.
Changed:
U zope.app.http/trunk/setup.py
U zope.app.http/trunk/src/zope/app/http/tests/test_delete.py
U zope.app.http/trunk/src/zope/app/http/tests/test_functional_put.py
U zope.app.http/trunk/src/zope/app/http/tests/test_options.py
U zope.app.http/trunk/src/zope/app/http/tests/test_put.py
-=-
Modified: zope.app.http/trunk/setup.py
===================================================================
--- zope.app.http/trunk/setup.py 2010-04-14 13:55:03 UTC (rev 110889)
+++ zope.app.http/trunk/setup.py 2010-04-14 14:05:18 UTC (rev 110890)
@@ -57,6 +57,8 @@
'zope.app.securitypolicy',
'zope.app.file',
'zope.app.zcmlfiles',
+ 'zope.app.wsgi',
+ 'zope.site',
'zope.login',]),
install_requires=['setuptools',
'zope.interface',
Modified: zope.app.http/trunk/src/zope/app/http/tests/test_delete.py
===================================================================
--- zope.app.http/trunk/src/zope/app/http/tests/test_delete.py 2010-04-14 13:55:03 UTC (rev 110889)
+++ zope.app.http/trunk/src/zope/app/http/tests/test_delete.py 2010-04-14 14:05:18 UTC (rev 110890)
@@ -22,7 +22,6 @@
from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
import zope.app.http.delete
-from zope.app.testing.placelesssetup import PlacelessSetup
from zope.container.contained import contained
from zope.publisher.interfaces.http import MethodNotAllowed
@@ -38,7 +37,7 @@
delattr(self, name)
-class TestDelete(PlacelessSetup, TestCase):
+class TestDelete(TestCase):
def test(self):
container = Container()
Modified: zope.app.http/trunk/src/zope/app/http/tests/test_functional_put.py
===================================================================
--- zope.app.http/trunk/src/zope/app/http/tests/test_functional_put.py 2010-04-14 13:55:03 UTC (rev 110889)
+++ zope.app.http/trunk/src/zope/app/http/tests/test_functional_put.py 2010-04-14 14:05:18 UTC (rev 110890)
@@ -16,45 +16,52 @@
$Id$
"""
-from unittest import TestSuite, makeSuite
+from unittest import TestSuite, TestCase, makeSuite
-from zope.app.testing.functional import FunctionalTestCase, HTTPCaller
-from zope.app.http.testing import AppHttpLayer
+from zope.app.wsgi.testlayer import http, BrowserLayer
+import zope.app.http
-class TestPUT(FunctionalTestCase):
+layer = BrowserLayer(zope.app.http)
+
+class TestPUT(TestCase):
def test_put(self):
# PUT something for the first time
- response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
-Authorization: Basic bWdyOm1ncnB3
+ out = http(r"""PUT /testfile.txt HTTP/1.1
+Authorization: Basic globalmgr:globalmgrpw
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.")
-
+ self.assertEquals(
+ out,
+ ('HTTP/1.0 201 Created\n'
+ 'X-Powered-By: Zope (www.zope.org), Python (www.python.org)\n'
+ 'Content-Length: 0\n'
+ 'Location: http://localhost/testfile.txt\n\n'))
+
+ out = http(r"""GET /testfile.txt HTTP/1.1
+Authorization: Basic globalmgr:globalmgrpw""")
+ self.assertEquals(out.split('\n\n')[1],
+ 'This is just a test.')
+
# now modify it
- response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
-Authorization: Basic bWdyOm1ncnB3
+ out = http(r"""PUT /testfile.txt HTTP/1.1
+Authorization: Basic globalmgr:globalmgrpw
Content-Length: 23
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.")
+ self.assert_('200' in out)
+ self.assertEquals(out.split('\n\n')[1], "")
+
+ out = http(r"""GET /testfile.txt HTTP/1.1
+Authorization: Basic globalmgr:globalmgrpw""")
+
+ self.assertEquals(out.split('\n\n')[1], "And now it is modified.")
-
def test_suite():
- TestPUT.layer = AppHttpLayer
+ TestPUT.layer = layer
return TestSuite((
makeSuite(TestPUT),
))
Modified: zope.app.http/trunk/src/zope/app/http/tests/test_options.py
===================================================================
--- zope.app.http/trunk/src/zope/app/http/tests/test_options.py 2010-04-14 13:55:03 UTC (rev 110889)
+++ zope.app.http/trunk/src/zope/app/http/tests/test_options.py 2010-04-14 14:05:18 UTC (rev 110890)
@@ -19,7 +19,6 @@
import zope.interface
-from zope.app.testing.placelesssetup import PlacelessSetup
from zope.publisher.browser import IBrowserRequest
from zope.publisher.browser import TestRequest
@@ -42,7 +41,7 @@
self.request = request
-class TestOptions(PlacelessSetup, TestCase):
+class TestOptions(TestCase):
def testDefaultMethods(self):
dumbObj = object()
Modified: zope.app.http/trunk/src/zope/app/http/tests/test_put.py
===================================================================
--- zope.app.http/trunk/src/zope/app/http/tests/test_put.py 2010-04-14 13:55:03 UTC (rev 110889)
+++ zope.app.http/trunk/src/zope/app/http/tests/test_put.py 2010-04-14 14:05:18 UTC (rev 110890)
@@ -23,10 +23,11 @@
from zope.filerepresentation.interfaces import IWriteFile
from zope.filerepresentation.interfaces import IWriteDirectory, IReadDirectory, IFileFactory
+
import zope.app.http.put
-from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.component.testing import PlacefulSetup, Place
from zope.location.interfaces import ILocation
+from zope.site.folder import rootFolder
+from zope.app.wsgi.testlayer import BrowserLayer
class File(object):
@@ -40,12 +41,15 @@
def write(self, data):
self.data = data
-class Container(Place):
+class Container(object):
implements(IWriteDirectory, IReadDirectory, IFileFactory, ILocation)
__name__ = None
__parent__ = None
+
+ def __init__(self, path):
+ self.path = path
def __setitem__(self, name, object):
object.__name__ = name
@@ -59,9 +63,13 @@
return File(name, content_type, data)
-class TestNullPUT(PlacefulSetup, TestCase):
+class TestNullPUT(TestCase):
+ layer = BrowserLayer(zope.app.http)
+
def test(self):
+ self.rootFolder = rootFolder()
+
container = Container("put")
self.rootFolder["put"] = container
content = "some content\n for testing"
@@ -90,6 +98,7 @@
## object had a key beginning with 'HTTP_CONTENT_' with a status of 501.
## This was breaking the new Twisted server, so I am now allowing this
## this type of request to be valid.
+ self.rootFolder = rootFolder()
container = Container("/put")
self.rootFolder["put"] = container
content = "some content\n for testing"
@@ -107,7 +116,8 @@
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 201)
-class TestFilePUT(PlacelessSetup, TestCase):
+class TestFilePUT(TestCase):
+ layer = BrowserLayer(zope.app.http)
def test(self):
file = File("thefile", "text/x", "initial content")
More information about the checkins
mailing list