vendor/Five/1.2b-r20590

view browser/tests/pts_test_languages.txt @ 0:3673ed425f80

Vendor import of Five 1.2b+ (r20590)
author fguillaume
date Fri, 02 Dec 2005 20:25:42 +0000
parents
children
line source
1 PTS languages
2 =============
4 Before we start, we need to set up a manager user to be able to create
5 the portal:
7 >>> uf = self.folder.acl_users
8 >>> uf._doAddUser('manager', 'r00t', ['Manager'], [])
10 We need to 1) configure the Zope 3 i18n message catalogs, 3) register
11 the PTS languagees adapter and 3) register our test page:
13 >>> configure_zcml = """
14 ... <configure
15 ... xmlns="http://namespaces.zope.org/zope"
16 ... xmlns:browser="http://namespaces.zope.org/browser"
17 ... xmlns:i18n="http://namespaces.zope.org/i18n"
18 ... >
19 ... <configure package="Products.Five.tests">
20 ... <i18n:registerTranslations directory="locales" />
21 ... </configure>
22 ...
23 ... <adapter
24 ... for="zope.publisher.interfaces.http.IHTTPRequest"
25 ... provides="zope.i18n.interfaces.IUserPreferredLanguages"
26 ... factory="Products.Five.i18n.PTSLanguages"
27 ... />
28 ...
29 ... <configure package="Products.Five.browser.tests">
30 ... <browser:page
31 ... for="Products.Five.interfaces.IFolder"
32 ... template="pts_test_languages.pt"
33 ... name="pts_test_languages.html"
34 ... permission="zope2.View"
35 ... />
36 ... </configure>
37 ... </configure>
38 ... """
39 >>> from Products.Five import zcml
40 >>> zcml.load_string(configure_zcml)
42 Finally, we need a traversable folder so that the test page we
43 registered is found:
45 >>> from Products.Five.tests.testing import manage_addFiveTraversableFolder
46 >>> manage_addFiveTraversableFolder(self.folder, 'ftf')
48 Now for some actual testing... Our test page is a simple ZPT
49 translating two messages from different domains. The first domain is
50 a Zope 3 style one, the second one comes from PTS.
52 Both systems should yield the same default language (English) when no
53 language is specified whatsoever:
55 >>> print http(r"""
56 ... GET /test_folder_1_/ftf/pts_test_languages.html HTTP/1.1
57 ... """)
58 HTTP/1.1 200 OK
59 ...
60 <html>
61 <body>
62 <!-- fivetest is a Zope 3 style i18n domain, default is a PTS domain -->
63 <p>This is a message</p>
64 <p>Reload this catalog</p>
65 </body>
66 </html>
68 Both systems should honour the HTTP ``Accept-Language`` header in the
69 same way:
71 >>> print http(r"""
72 ... GET /test_folder_1_/ftf/pts_test_languages.html HTTP/1.1
73 ... Accept-Language: de
74 ... """)
75 HTTP/1.1 200 OK
76 ...
77 <html>
78 <body>
79 <!-- fivetest is a Zope 3 style i18n domain, default is a PTS domain -->
80 <p>Dies ist eine Nachricht</p>
81 <p>Diesen Katalog neu einlesen</p>
82 </body>
83 </html>
85 Both systems should also honour Localizer-specific ways of determining
86 the language, for example the ``pts_language`` cookie...
88 >>> print http(r"""
89 ... GET /test_folder_1_/ftf/pts_test_languages.html HTTP/1.1
90 ... Accept-Language: de
91 ... Cookie: pts_language=en
92 ... """)
93 HTTP/1.1 200 OK
94 ...
95 <html>
96 <body>
97 <!-- fivetest is a Zope 3 style i18n domain, default is a PTS domain -->
98 <p>This is a message</p>
99 <p>Reload this catalog</p>
100 </body>
101 </html>
103 ... and the ``language`` form field...
105 >>> print http(r"""
106 ... GET /test_folder_1_/ftf/pts_test_languages.html?language=en HTTP/1.1
107 ... Accept-Language: de
108 ... """)
109 HTTP/1.1 200 OK
110 ...
111 <html>
112 <body>
113 <!-- fivetest is a Zope 3 style i18n domain, default is a PTS domain -->
114 <p>This is a message</p>
115 <p>Reload this catalog</p>
116 </body>
117 </html>
119 ... and both the ``pts_language`` cookie and the ``language`` form field:
121 >>> print http(r"""
122 ... GET /test_folder_1_/ftf/pts_test_languages.html?language=de HTTP/1.1
123 ... Accept-Language: en
124 ... Cookie: pts_language=fr
125 ... """)
126 HTTP/1.1 200 OK
127 ...
128 <html>
129 <body>
130 <!-- fivetest is a Zope 3 style i18n domain, default is a PTS domain -->
131 <p>Dies ist eine Nachricht</p>
132 <p>Diesen Katalog neu einlesen</p>
133 </body>
134 </html>