[Checkins] SVN: Sandbox/janwijbrand/zope.errorview/trunk/s get tests running again.
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Tue Jan 18 09:58:35 EST 2011
Log message for revision 119650:
get tests running again.
Changed:
U Sandbox/janwijbrand/zope.errorview/trunk/setup.py
U Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py
U Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py
-=-
Modified: Sandbox/janwijbrand/zope.errorview/trunk/setup.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/setup.py 2011-01-18 14:48:23 UTC (rev 119649)
+++ Sandbox/janwijbrand/zope.errorview/trunk/setup.py 2011-01-18 14:58:35 UTC (rev 119650)
@@ -49,11 +49,14 @@
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
- namespace_packages=['zope''],
+ namespace_packages=['zope'],
extras_require={'test':[]},
install_requires=[
'setuptools',
+ 'zope.component',
'zope.interface',
+ 'zope.publisher',
+ 'zope.security',
],
include_package_data=True,
zip_safe=False,
Modified: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py 2011-01-18 14:48:23 UTC (rev 119649)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py 2011-01-18 14:58:35 UTC (rev 119650)
@@ -18,101 +18,75 @@
from unittest import TestCase, TestSuite, main, makeSuite
from StringIO import StringIO
+from zope.component import provideAdapter
+from zope.errorview.methodnotallowed import MethodNotAllowedView
from zope.interface import Interface, implements
+from zope.publisher.browser import BrowserRequest
from zope.publisher.http import HTTPRequest
-from zope.publisher.interfaces.http import IHTTPRequest
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.http import IHTTPRequest, MethodNotAllowed
+from zope.publisher.interfaces import IDefaultViewName
-from zope.component import provideAdapter
-
-
class I(Interface):
pass
-
class C(object):
implements(I)
-
class GetView(object):
def __init__(self, context, request):
pass
def GET(self):
pass
-
class DeleteView(object):
def __init__(self, context, request):
pass
def DELETE(self):
pass
-
class TestMethodNotAllowedView(TestCase):
def setUp(self):
- from zope.publisher.interfaces.http import IHTTPRequest
-
provideAdapter(GetView, (I, IHTTPRequest), Interface, 'GET')
provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'DELETE')
provideAdapter(GetView, (I, IHTTPRequest), Interface, 'irrelevant')
provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'also_irr.')
-
- from zope.publisher.interfaces import IDefaultViewName
- from zope.publisher.interfaces.browser import IBrowserRequest
- #do the same as defaultView would for something like:
- #<defaultView
- # for=".test_methodnotallowed.I"
- # name="index.html"
- # />
-
+ # Do the same as defaultView would for something like:
+ # <defaultView
+ # for=".test_methodnotallowed.I"
+ # name="index.html"
+ # />
provideAdapter(u'index.html', (I, IBrowserRequest), IDefaultViewName)
-
- def test(self):
- from zope.publisher.interfaces.http import MethodNotAllowed
- from zope.app.http.exception.methodnotallowed \
- import MethodNotAllowedView
- from zope.publisher.http import HTTPRequest
+ def test(self):
context = C()
request = HTTPRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
error = MethodNotAllowed(context, request)
view = MethodNotAllowedView(error, request)
-
result = view()
-
self.assertEqual(request.response.getStatus(), 405)
self.assertEqual(request.response.getHeader('Allow'), 'DELETE, GET')
self.assertEqual(result, 'Method Not Allowed')
-
def test_defaultView(self):
- # do the same with a BrowserRequest
- # edge case is that if someone does a defaultView for the context object
- # but the app is not prepared for webdav or whatever
- # and someone comes with a not allowed method, the exception
- # view fails on getAdapters
- # this might be an issue with zope.publisher, as it provides
- # a unicode object with provideAdapter, but I don't think I can
+ # Do the same with a BrowserRequest edge case is that if someone
+ # does a defaultView for the context object but the app is
+ # not prepared for webdav or whatever and someone comes with a
+ # not allowed method, the exception view fails on getAdapters
+ # this might be an issue with zope.publisher, as it provides a
+ # unicode object with provideAdapter, but I don't think I can
# change zope.publisher
- from zope.publisher.interfaces.http import MethodNotAllowed
- from zope.app.http.exception.methodnotallowed \
- import MethodNotAllowedView
- from zope.publisher.browser import BrowserRequest
-
context = C()
request = BrowserRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
-
error = MethodNotAllowed(context, request)
view = MethodNotAllowedView(error, request)
-
result = view()
-
self.assertEqual(request.response.getStatus(), 405)
- #well this is empty, but we're grateful that it does not break
+ # Well this is empty, but we're grateful that it does not break.
self.assertEqual(request.response.getHeader('Allow'), '')
self.assertEqual(result, 'Method Not Allowed')
-
def test_suite():
return TestSuite((
makeSuite(TestMethodNotAllowedView),
Modified: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py 2011-01-18 14:48:23 UTC (rev 119649)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py 2011-01-18 14:58:35 UTC (rev 119650)
@@ -16,13 +16,13 @@
$Id$
"""
from unittest import TestCase, main, makeSuite
+from zope.errorview.unauthorized import Unauthorized
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.http import IHTTPException
class Test(TestCase):
def testbasicauth(self):
- from zope.app.http.exception.unauthorized import Unauthorized
exception = Exception()
try:
raise exception
@@ -30,16 +30,14 @@
pass
request = TestRequest()
u = Unauthorized(exception, request)
-
- # Chech that we implement the right interface
+ # Check that we implement the right interface.
self.failUnless(IHTTPException.providedBy(u))
-
- # Call the view
+ # Call the view.
u()
-
- # Make sure the response status was set
+ # Make sure the response status was set.
self.assertEqual(request.response.getStatus(), 401)
- self.failUnless(request.response.getHeader('WWW-Authenticate', '', True).startswith('basic'))
+ self.failUnless(request.response.getHeader(
+ 'WWW-Authenticate', '', True).startswith('basic'))
def test_suite():
return makeSuite(Test)
More information about the checkins
mailing list