web/test/unittest_views_pyviews.py
author Julien Jehannet <julien.jehannet@logilab.fr>
Thu, 22 Apr 2010 17:04:51 +0200
changeset 5373 24a873060692
parent 4916 4b8cdda342ae
child 5421 8167de96c523
permissions -rw-r--r--
[selector] allow inplace operator in selector computation Intended to facilitate overriding of existing selectors chain in view declaration. It make the code shorter and clearer when you've to import long module pathnames
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
from logilab.common.testlib import unittest_main
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2650
diff changeset
     2
from cubicweb.devtools.testlib import CubicWebTC
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2650
diff changeset
     4
class PyViewsTC(CubicWebTC):
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
    def test_pyvaltable(self):
3468
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
     7
        view = self.vreg['views'].select('pyvaltable', self.request(),
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
     8
                                         pyvalue=[[1, 'a'], [2, 'b']])
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
     9
        content = view.render(pyvalue=[[1, 'a'], [2, 'b']],
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
    10
                              headers=['num', 'char'])
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
        self.assertEquals(content.strip(), '''<table class="listing">
4916
4b8cdda342ae fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468
diff changeset
    12
<thead><tr><th>num</th><th>char</th></tr>
4b8cdda342ae fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468
diff changeset
    13
</thead><tbody><tr><td>1</td><td>a</td></tr>
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
<tr><td>2</td><td>b</td></tr>
4916
4b8cdda342ae fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468
diff changeset
    15
</tbody></table>''')
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
    def test_pyvallist(self):
3468
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
    18
        view = self.vreg['views'].select('pyvallist', self.request(),
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
    19
                                         pyvalue=[1, 'a'])
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2773
diff changeset
    20
        content = view.render(pyvalue=[1, 'a'])
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
        self.assertEquals(content.strip(), '''<ul>
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
<li>1</li>
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
<li>a</li>
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
</ul>''')
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
if __name__ == '__main__':
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
    unittest_main()