[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testBrowserCharsets.py:1.1

Stephan Richter srichter@cbu.edu
Fri, 14 Jun 2002 04:56:30 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv23607/Zope/Publisher/Browser/tests

Added Files:
	testBrowserCharsets.py 
Log Message:
Similar to the Language Negotiator I created a Charset negotiator, which 
should help us with defining an output charset for the browser.


=== Added File Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserCharsets.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""Retrieval of browser character set information.

$Id: testBrowserCharsets.py,v 1.1 2002/06/14 08:56:29 srichter Exp $
"""
import unittest, sys

from Zope.Publisher.Browser.BrowserCharsets import BrowserCharsets


class BrowserCharsetTest(unittest.TestCase):

    def testGetPreferredCharset(self):
        request = {'HTTP_ACCEPT_CHARSET':
                   'ISO-8859-1, UTF-8;q=0.66, UTF-16;q=0.33'}

        browser_charsets = BrowserCharsets(request)

        self.assertEqual(list(browser_charsets.getPreferredCharsets()),
                         ['ISO-8859-1', 'UTF-8', 'UTF-16'])


def test_suite():
    loader=unittest.TestLoader()
    return loader.loadTestsFromTestCase(BrowserCharsetTest)

if __name__=='__main__':
    unittest.TextTestRunner().run(test_suite())