[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testBrowserLanguages.py:1.1.2.1
Jim Fulton
jim@zope.com
Fri, 18 Jan 2002 15:48:37 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv21968/tests
Added Files:
Tag: Zope-3x-branch
testBrowserLanguages.py
Log Message:
Juan David Ibenez Palomar and Jim
Added an adapter for getting user-prefered languages from a browser
using HTTP headers.
=== Added File Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserLanguages.py ===
##############################################################################
#
# Copyright (c) 2001 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
#
##############################################################################
import unittest, sys
class Test(unittest.TestCase):
def test(self):
request = {'HTTP_ACCEPT_LANGUAGE': 'da, en-gb;q=0.8, en;q=0.7'}
from Zope.Publisher.Browser.BrowserLanguages import BrowserLanguages
browser_languages = BrowserLanguages(request)
self.assertEqual(list(browser_languages.getLanguages()),
['da', 'en-gb', 'en'])
# XXX Add support for quality statements
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())