author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 19 Mar 2013 15:17:34 +0100 | |
changeset 8734 | 3530b7494195 |
parent 8694 | d901c36bcfce |
child 8941 | 7b26fe71404f |
permissions | -rw-r--r-- |
7992
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7187
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1654
diff
changeset
|
18 |
|
0 | 19 |
from logilab.common.testlib import unittest_main |
20 |
from logilab.mtconverter import html_unescape |
|
21 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
22 |
from cubicweb.devtools.testlib import CubicWebTC |
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
23 |
from cubicweb.utils import json |
7187
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
24 |
from cubicweb.view import StartupView, TRANSITIONAL_DOCTYPE_NOEXT |
0 | 25 |
from cubicweb.web.htmlwidgets import TableWidget |
1654 | 26 |
from cubicweb.web.views import vid_from_rset |
0 | 27 |
|
28 |
def loadjson(value): |
|
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
29 |
return json.loads(html_unescape(value)) |
0 | 30 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
31 |
class VidFromRsetTC(CubicWebTC): |
1654 | 32 |
|
0 | 33 |
def test_no_rset(self): |
34 |
req = self.request() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
35 |
self.assertEqual(vid_from_rset(req, None, self.schema), 'index') |
1654 | 36 |
|
0 | 37 |
def test_no_entity(self): |
38 |
req = self.request() |
|
39 |
rset = self.execute('Any X WHERE X login "blabla"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
40 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'noresult') |
0 | 41 |
|
42 |
def test_one_entity(self): |
|
43 |
req = self.request() |
|
44 |
rset = self.execute('Any X WHERE X login "admin"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
45 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
0 | 46 |
rset = self.execute('Any X, L WHERE X login "admin", X login L') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
47 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
0 | 48 |
req.search_state = ('pasnormal',) |
49 |
rset = self.execute('Any X WHERE X login "admin"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
50 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'outofcontext-search') |
0 | 51 |
|
52 |
def test_one_entity_eid(self): |
|
53 |
req = self.request() |
|
54 |
rset = self.execute('Any X WHERE X eid 1') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
55 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
1654 | 56 |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
57 |
def test_more_than_one_entity_same_type(self): |
0 | 58 |
req = self.request() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
59 |
rset = self.execute('Any X WHERE X is CWUser') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
60 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'sameetypelist') |
0 | 61 |
rset = self.execute('Any X, L WHERE X login L') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
62 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'sameetypelist') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
63 |
|
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
64 |
def test_more_than_one_entity_diff_type(self): |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
65 |
req = self.request() |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
66 |
rset = self.execute('Any X WHERE X is IN (CWUser, CWGroup)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
67 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'list') |
1654 | 68 |
|
0 | 69 |
def test_more_than_one_entity_by_row(self): |
70 |
req = self.request() |
|
71 |
rset = self.execute('Any X, G WHERE X in_group G') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
72 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
1654 | 73 |
|
0 | 74 |
def test_more_than_one_entity_by_row_2(self): |
75 |
req = self.request() |
|
76 |
rset = self.execute('Any X, GN WHERE X in_group G, G name GN') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
77 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
1654 | 78 |
|
0 | 79 |
def test_aggregat(self): |
80 |
req = self.request() |
|
81 |
rset = self.execute('Any X, COUNT(T) GROUPBY X WHERE X is T') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
82 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
83 |
rset = self.execute('Any MAX(X) WHERE X is CWUser') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
84 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
0 | 85 |
|
86 |
def test_subquery(self): |
|
87 |
rset = self.execute( |
|
88 |
'DISTINCT Any X,N ORDERBY N ' |
|
89 |
'WITH X,N BEING (' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
90 |
' (DISTINCT Any P,N WHERE P is CWUser, P login N)' |
0 | 91 |
' UNION' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
92 |
' (DISTINCT Any W,N WHERE W is CWGroup, W name N))') |
0 | 93 |
req = self.request() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
94 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
0 | 95 |
|
96 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
97 |
class TableViewTC(CubicWebTC): |
0 | 98 |
|
99 |
def _prepare_entity(self): |
|
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
100 |
req = self.request() |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
101 |
e = req.create_entity("State", name=u'<toto>', description=u'loo"ong blabla') |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
102 |
rset = req.execute('Any X, D, CD, NOW - CD WHERE X is State, X description D, X creation_date CD, X eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4494
diff
changeset
|
103 |
{'x': e.eid}) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2637
diff
changeset
|
104 |
view = self.vreg['views'].select('table', req, rset=rset) |
0 | 105 |
return e, rset, view |
1654 | 106 |
|
0 | 107 |
def test_headers(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
108 |
self.skipTest('implement me') |
0 | 109 |
|
110 |
def test_sortvalue(self): |
|
111 |
e, _, view = self._prepare_entity() |
|
7992
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7187
diff
changeset
|
112 |
colrenderers = view.build_column_renderers()[:3] |
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7187
diff
changeset
|
113 |
self.assertListEqual([renderer.sortvalue(0) for renderer in colrenderers], |
8001
35d673b05e84
[test] limit size is now done by the layout
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7992
diff
changeset
|
114 |
[u'<toto>', u'loo"ong blabla', e.creation_date]) |
0 | 115 |
# XXX sqlite does not handle Interval correctly |
116 |
# value = loadjson(view.sortvalue(0, 3)) |
|
117 |
# self.assertAlmostEquals(value, rset.rows[0][3].seconds) |
|
118 |
||
119 |
||
7187
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
120 |
class HTMLStreamTests(CubicWebTC): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
121 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
122 |
def test_set_doctype_reset_xmldecl(self): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
123 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
124 |
tests `cubicweb.web.request.CubicWebRequestBase.set_doctype` |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
125 |
with xmldecl reset |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
126 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
127 |
class MyView(StartupView): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
128 |
__regid__ = 'my-view' |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
129 |
def call(self): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
130 |
self._cw.set_doctype('<!DOCTYPE html>') |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
131 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
132 |
with self.temporary_appobjects(MyView): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
133 |
html_source = self.view('my-view').source |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
134 |
source_lines = [line.strip() for line in html_source.splitlines(False) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
135 |
if line.strip()] |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
136 |
self.assertListEqual(source_lines[:2], |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
137 |
['<!DOCTYPE html>', |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
138 |
'<html xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb" xml:lang="en" lang="en">']) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
139 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
140 |
def test_set_doctype_no_reset_xmldecl(self): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
141 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
142 |
tests `cubicweb.web.request.CubicWebRequestBase.set_doctype` |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
143 |
with no xmldecl reset |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
144 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
145 |
html_doctype = TRANSITIONAL_DOCTYPE_NOEXT.strip() |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
146 |
class MyView(StartupView): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
147 |
__regid__ = 'my-view' |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
148 |
def call(self): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
149 |
self._cw.set_doctype(html_doctype, reset_xmldecl=False) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
150 |
self._cw.main_stream.set_namespaces([('xmlns', 'http://www.w3.org/1999/xhtml')]) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
151 |
self._cw.main_stream.set_htmlattrs([('lang', 'cz')]) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
152 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
153 |
with self.temporary_appobjects(MyView): |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
154 |
html_source = self.view('my-view').source |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
155 |
source_lines = [line.strip() for line in html_source.splitlines(False) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
156 |
if line.strip()] |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
157 |
self.assertListEqual(source_lines[:3], |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
158 |
['<?xml version="1.0" encoding="UTF-8"?>', |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
159 |
html_doctype, |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
160 |
'<html xmlns="http://www.w3.org/1999/xhtml" lang="cz">']) |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
161 |
|
0 | 162 |
if __name__ == '__main__': |
163 |
unittest_main() |