Commit 6804ea09 authored by Tres Seaver's avatar Tres Seaver

Forward port fix for LP #239636 from the 2.9 branch.

parent 91e4ac61
......@@ -71,6 +71,7 @@ class NullResource(Persistent, Acquisition.Implicit, Resource):
def HEAD(self, REQUEST, RESPONSE):
"""Retrieve resource information without a response message body."""
self.dav__init(REQUEST, RESPONSE)
RESPONSE.setBody('', lock=True)
raise NotFound, 'The requested resource does not exist.'
# Most methods return 404 (Not Found) for null resources.
......
......@@ -20,20 +20,46 @@ class TestLockNullResource(unittest.TestCase):
class TestNullResource(unittest.TestCase):
def _getTargetClass(self):
from webdav.NullResource import NullResource
return NullResource
def _makeOne(self, parent=None, name='nonesuch', **kw):
return self._getTargetClass()(parent, name, **kw)
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from webdav.NullResource import NullResource
from webdav.WriteLockInterface import WriteLockInterface
verifyClass(WriteLockInterface, NullResource)
verifyClass(WriteLockInterface, self._getTargetClass())
def test_z3interfaces(self):
from webdav.interfaces import IWriteLock
from webdav.NullResource import NullResource
from zope.interface.verify import verifyClass
verifyClass(IWriteLock, NullResource)
verifyClass(IWriteLock, self._getTargetClass())
def test_HEAD_locks_empty_body_before_raising_NotFound(self):
from zExceptions import NotFound
# See https://bugs.launchpad.net/bugs/239636
class DummyResponse:
_server_version = 'Dummy' # emulate ZServer response
locked = False
body = None
def setHeader(self, *args):
pass
def setBody(self, body, lock=False):
self.body = body
self.locked = bool(lock)
nonesuch = self._makeOne()
request = {}
response = DummyResponse()
self.assertRaises(NotFound, nonesuch.HEAD, request, response)
self.assertEqual(response.body, '')
self.failUnless(response.locked)
def test_suite():
return unittest.TestSuite((
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment