Commit b051a119 authored by Tres Seaver's avatar Tres Seaver

Collector #2136: Map ResourceLockedError to the correct response code.

parent a9a9a0b5
...@@ -18,6 +18,8 @@ Zope Changes ...@@ -18,6 +18,8 @@ Zope Changes
Bugs fixed Bugs fixed
- Collector #2136: Map ResourceLockedError to the correct response code.
- Collector #2109: XML-RPC did not handle DateTime.DateTime objects. - Collector #2109: XML-RPC did not handle DateTime.DateTime objects.
- Collector #2016: DemoStorage couldn't wrap base storages without - Collector #2016: DemoStorage couldn't wrap base storages without
......
...@@ -97,6 +97,7 @@ for name in en: ...@@ -97,6 +97,7 @@ for name in en:
status_codes['nameerror'] = 503 status_codes['nameerror'] = 503
status_codes['keyerror'] = 503 status_codes['keyerror'] = 503
status_codes['redirect'] = 300 status_codes['redirect'] = 300
status_codes['resourcelockederror'] = 423
start_of_header_search = re.compile('(<head[^>]*>)', re.IGNORECASE).search start_of_header_search = re.compile('(<head[^>]*>)', re.IGNORECASE).search
......
...@@ -51,7 +51,8 @@ class HTTPResponseTests(unittest.TestCase): ...@@ -51,7 +51,8 @@ class HTTPResponseTests(unittest.TestCase):
# Verify that the cookie is expired even if an expires kw arg is passed # Verify that the cookie is expired even if an expires kw arg is passed
# http://zope.org/Collectors/Zope/1160 # http://zope.org/Collectors/Zope/1160
response = self._makeOne() response = self._makeOne()
response.expireCookie('foo', path='/', expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99) response.expireCookie('foo', path='/',
expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99)
cookie = response.cookies.get('foo', None) cookie = response.cookies.get('foo', None)
self.failUnless(cookie) self.failUnless(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT') self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
...@@ -76,27 +77,43 @@ class HTTPResponseTests(unittest.TestCase): ...@@ -76,27 +77,43 @@ class HTTPResponseTests(unittest.TestCase):
response.appendHeader('XXX', 'foo') response.appendHeader('XXX', 'foo')
self.assertEqual(response.headers.get('xxx'), 'bar,\n\tfoo') self.assertEqual(response.headers.get('xxx'), 'bar,\n\tfoo')
def test_CharsetNoHeader(self): def test_setStatus_ResourceLockedError(self):
response = self._makeOne(body='foo') response = self._makeOne()
self.assertEqual(response.headers.get('content-type'), 'text/plain; charset=iso-8859-15') from webdav.Lockable import ResourceLockedError
response.setStatus(ResourceLockedError)
def test_CharsetTextHeader(self): self.assertEqual(response.status, 423)
response = self._makeOne(body='foo', headers={'content-type': 'text/plain'})
self.assertEqual(response.headers.get('content-type'), 'text/plain; charset=iso-8859-15')
def test_CharsetApplicationHeader(self): def test_charset_no_header(self):
response = self._makeOne(body='foo', headers={'content-type': 'application/foo'}) response = self._makeOne(body='foo')
self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=iso-8859-15') self.assertEqual(response.headers.get('content-type'),
'text/plain; charset=iso-8859-15')
def test_charset_text_header(self):
response = self._makeOne(body='foo',
headers={'content-type': 'text/plain'})
self.assertEqual(response.headers.get('content-type'),
'text/plain; charset=iso-8859-15')
def test_charset_application_header(self):
response = self._makeOne(body='foo',
headers={'content-type': 'application/foo'})
self.assertEqual(response.headers.get('content-type'),
'application/foo; charset=iso-8859-15')
def test_CharsetApplicationHeaderUnicode(self): def test_charset_application_header_unicode(self):
response = self._makeOne(body=unicode('rger', 'iso-8859-15'), headers={'content-type': 'application/foo'}) response = self._makeOne(body=unicode('rger', 'iso-8859-15'),
self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=iso-8859-15') headers={'content-type': 'application/foo'})
self.assertEqual(response.headers.get('content-type'),
'application/foo; charset=iso-8859-15')
self.assertEqual(response.body, 'rger') self.assertEqual(response.body, 'rger')
def test_CharsetApplicationHeader1Unicode(self): def test_charset_application_header_unicode_1(self):
response = self._makeOne(body=unicode('rger', 'iso-8859-15'), headers={'content-type': 'application/foo; charset=utf-8'}) response = self._makeOne(body=unicode('rger', 'iso-8859-15'),
self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=utf-8') headers={'content-type': 'application/foo; charset=utf-8'})
self.assertEqual(response.body, unicode('rger', 'iso-8859-15').encode('utf-8')) self.assertEqual(response.headers.get('content-type'),
'application/foo; charset=utf-8')
self.assertEqual(response.body, unicode('rger',
'iso-8859-15').encode('utf-8'))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = 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