[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/HTTP/tests - testHTTPCharsets.py:1.3
Fred L. Drake, Jr.
fdrake@acm.org
Fri, 14 Jun 2002 13:33:32 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/HTTP/tests
In directory cvs.zope.org:/tmp/cvs-serv32035/HTTP/tests
Modified Files:
testHTTPCharsets.py
Log Message:
Move my changes from BrowserCharsets (now obsolete) to HTTPCharsets,
and update affected tests.
Remove the now-obslete BrowserCharsets module and its test.
=== Zope3/lib/python/Zope/Publisher/HTTP/tests/testHTTPCharsets.py 1.2 => 1.3 ===
'ISO-8859-1, UTF-8;q=0.66, UTF-16;q=0.33'}
- http_charsets = HTTPCharsets(request)
+ browser_charsets = HTTPCharsets(request)
- self.assertEqual(list(http_charsets.getPreferredCharsets()),
- ['UTF-8', 'ISO-8859-1', 'UTF-16'])
+ self.assertEqual(list(browser_charsets.getPreferredCharsets()),
+ ['utf-8', 'iso-8859-1', 'utf-16'])
+
+ def testGetPreferredCharsetOrdering(self):
+ # test that the charsets are returned sorted according to
+ # their "quality value"
+ request = {'HTTP_ACCEPT_CHARSET':
+ 'ISO-8859-1, UTF-16;Q=0.33, UTF-8;q=0.66'}
+
+ browser_charsets = HTTPCharsets(request)
+
+ self.assertEqual(list(browser_charsets.getPreferredCharsets()),
+ ['utf-8', 'iso-8859-1', 'utf-16'])
+
+ def testGetPreferredCharsetBogusQuality(self):
+ # test that handling of bogus "quality values" and non-quality
+ # parameters is reasonable
+ request = {'HTTP_ACCEPT_CHARSET':
+ 'ISO-8859-1;x, UTF-16;Q=0.33, UTF-8;q=foo'}
+
+ browser_charsets = HTTPCharsets(request)
+
+ self.assertEqual(list(browser_charsets.getPreferredCharsets()),
+ ['iso-8859-1', 'utf-16'])
def test_suite():