Commit 25f75d09 authored by Tres Seaver's avatar Tres Seaver

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

parent f96be5fc
......@@ -18,6 +18,8 @@ Zope Changes
Bugs Fixed
- Collector #2136: Map ResourceLockedError to the correct response code.
- Collector #2016: DemoStorage couldn't wrap base storages without
an '_oid' attribute.
......
......@@ -97,6 +97,7 @@ for name in en:
status_codes['nameerror'] = 503
status_codes['keyerror'] = 503
status_codes['redirect'] = 300
status_codes['resourcelockederror'] = 423
start_of_header_search = re.compile('(<head[^>]*>)', re.IGNORECASE).search
......
......@@ -51,7 +51,8 @@ class HTTPResponseTests(unittest.TestCase):
# Verify that the cookie is expired even if an expires kw arg is passed
# http://zope.org/Collectors/Zope/1160
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)
self.failUnless(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
......@@ -76,27 +77,43 @@ class HTTPResponseTests(unittest.TestCase):
response.appendHeader('XXX', 'foo')
self.assertEqual(response.headers.get('xxx'), 'bar,\n\tfoo')
def test_CharsetNoHeader(self):
response = self._makeOne(body='foo')
self.assertEqual(response.headers.get('content-type'), 'text/plain; charset=iso-8859-15')
def test_CharsetTextHeader(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_setStatus_ResourceLockedError(self):
response = self._makeOne()
from webdav.Lockable import ResourceLockedError
response.setStatus(ResourceLockedError)
self.assertEqual(response.status, 423)
def test_CharsetApplicationHeader(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_charset_no_header(self):
response = self._makeOne(body='foo')
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):
response = self._makeOne(body=unicode('rger', 'iso-8859-15'), headers={'content-type': 'application/foo'})
self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=iso-8859-15')
def test_charset_application_header_unicode(self):
response = self._makeOne(body=unicode('rger', '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')
def test_CharsetApplicationHeader1Unicode(self):
response = self._makeOne(body=unicode('rger', 'iso-8859-15'), headers={'content-type': 'application/foo; charset=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_charset_application_header_unicode_1(self):
response = self._makeOne(body=unicode('rger', 'iso-8859-15'),
headers={'content-type': 'application/foo; charset=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_XMLEncodingRecoding(self):
xml = u'<?xml version="1.0" encoding="iso-8859-15" ?>\n<foo><bar/></foo>'
......
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