author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 09 May 2012 17:15:44 +0200 | |
changeset 8394 | b8b23af60019 |
parent 8001 | 35d673b05e84 |
child 8694 | d901c36bcfce |
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 |
|
7187
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
19 |
from __future__ import with_statement |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
20 |
|
0 | 21 |
from logilab.common.testlib import unittest_main |
22 |
from logilab.mtconverter import html_unescape |
|
23 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
24 |
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
|
25 |
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
|
26 |
from cubicweb.view import StartupView, TRANSITIONAL_DOCTYPE_NOEXT |
0 | 27 |
from cubicweb.web.htmlwidgets import TableWidget |
1654 | 28 |
from cubicweb.web.views import vid_from_rset |
0 | 29 |
|
30 |
def loadjson(value): |
|
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
31 |
return json.loads(html_unescape(value)) |
0 | 32 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
33 |
class VidFromRsetTC(CubicWebTC): |
1654 | 34 |
|
0 | 35 |
def test_no_rset(self): |
36 |
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
|
37 |
self.assertEqual(vid_from_rset(req, None, self.schema), 'index') |
1654 | 38 |
|
0 | 39 |
def test_no_entity(self): |
40 |
req = self.request() |
|
41 |
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
|
42 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'noresult') |
0 | 43 |
|
44 |
def test_one_entity(self): |
|
45 |
req = self.request() |
|
46 |
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
|
47 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
0 | 48 |
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
|
49 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
0 | 50 |
req.search_state = ('pasnormal',) |
51 |
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
|
52 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'outofcontext-search') |
0 | 53 |
|
54 |
def test_one_entity_eid(self): |
|
55 |
req = self.request() |
|
56 |
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
|
57 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'primary') |
1654 | 58 |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
59 |
def test_more_than_one_entity_same_type(self): |
0 | 60 |
req = self.request() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
61 |
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
|
62 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'sameetypelist') |
0 | 63 |
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
|
64 |
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
|
65 |
|
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
66 |
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
|
67 |
req = self.request() |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
68 |
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
|
69 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'list') |
1654 | 70 |
|
0 | 71 |
def test_more_than_one_entity_by_row(self): |
72 |
req = self.request() |
|
73 |
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
|
74 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
1654 | 75 |
|
0 | 76 |
def test_more_than_one_entity_by_row_2(self): |
77 |
req = self.request() |
|
78 |
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
|
79 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
1654 | 80 |
|
0 | 81 |
def test_aggregat(self): |
82 |
req = self.request() |
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
0 | 87 |
|
88 |
def test_subquery(self): |
|
89 |
rset = self.execute( |
|
90 |
'DISTINCT Any X,N ORDERBY N ' |
|
91 |
'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
|
92 |
' (DISTINCT Any P,N WHERE P is CWUser, P login N)' |
0 | 93 |
' UNION' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
94 |
' (DISTINCT Any W,N WHERE W is CWGroup, W name N))') |
0 | 95 |
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
|
96 |
self.assertEqual(vid_from_rset(req, rset, self.schema), 'table') |
0 | 97 |
|
98 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
99 |
class TableViewTC(CubicWebTC): |
0 | 100 |
|
101 |
def _prepare_entity(self): |
|
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
102 |
req = self.request() |
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3777
diff
changeset
|
103 |
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
|
104 |
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
|
105 |
{'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
|
106 |
view = self.vreg['views'].select('table', req, rset=rset) |
0 | 107 |
return e, rset, view |
1654 | 108 |
|
0 | 109 |
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
|
110 |
self.skipTest('implement me') |
0 | 111 |
|
112 |
def test_sortvalue(self): |
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
[u'<toto>', u'loo"ong blabla', e.creation_date]) |
0 | 117 |
# XXX sqlite does not handle Interval correctly |
118 |
# value = loadjson(view.sortvalue(0, 3)) |
|
119 |
# self.assertAlmostEquals(value, rset.rows[0][3].seconds) |
|
120 |
||
121 |
||
7187
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
122 |
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
|
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 |
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
|
125 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
129 |
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
|
130 |
__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
|
131 |
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
|
132 |
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
|
133 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
['<!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
|
140 |
'<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
|
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 |
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
|
143 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
144 |
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
|
145 |
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
|
146 |
""" |
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
__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
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
|
496f51b92154
[views] extend HTMLStream API to be able to change doctype / xmldecl
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6340
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
['<?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
|
161 |
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
|
162 |
'<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
|
163 |
|
0 | 164 |
if __name__ == '__main__': |
165 |
unittest_main() |