author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 19 Feb 2009 22:17:39 +0100 | |
branch | tls-sprint |
changeset 868 | 5d993a0c794c |
parent 824 | a5e6acffde30 |
child 1016 | 26387b836099 |
permissions | -rw-r--r-- |
0 | 1 |
"""automatic tests""" |
2 |
||
3 |
from mx.DateTime import now |
|
4 |
||
5 |
from cubicweb.devtools.testlib import WebTest, AutomaticWebTest |
|
6 |
from cubicweb.common.view import AnyRsetView |
|
7 |
||
8 |
AutomaticWebTest.application_rql = [ |
|
9 |
'Any L,F WHERE E is EUser, E login L, E firstname F', |
|
10 |
'Any L,F,E WHERE E is EUser, E login L, E firstname F', |
|
11 |
'Any COUNT(X) WHERE X is EUser', |
|
12 |
] |
|
13 |
||
14 |
class ComposityCopy(WebTest): |
|
15 |
||
16 |
def test_regr_copy_view(self): |
|
17 |
"""regression test: make sure we can ask a copy of a |
|
18 |
composite entity |
|
19 |
""" |
|
20 |
rset = self.execute('EUser X WHERE X login "admin"') |
|
21 |
self.view('copy', rset) |
|
22 |
||
23 |
||
24 |
||
25 |
class SomeView(AnyRsetView): |
|
26 |
id = 'someview' |
|
27 |
||
28 |
def call(self): |
|
29 |
self.req.add_js('spam.js') |
|
30 |
self.req.add_js('spam.js') |
|
31 |
||
32 |
||
33 |
class ManualWebTests(WebTest): |
|
34 |
def setup_database(self): |
|
35 |
self.auto_populate(10) |
|
36 |
||
37 |
def test_manual_tests(self): |
|
38 |
rset = self.execute('Any P,F,S WHERE P is EUser, P firstname F, P surname S') |
|
39 |
self.view('table', rset, template=None, displayfilter=True, displaycols=[0,2]) |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
569
diff
changeset
|
40 |
# rset = self.execute('Any P,F,S LIMIT 1 WHERE P is EUser, P firstname F, P surname S') |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
569
diff
changeset
|
41 |
# rset.req.form['rtype'] = 'firstname' |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
569
diff
changeset
|
42 |
# self.view('editrelation', rset, template=None) |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
569
diff
changeset
|
43 |
# rset.req.form['rtype'] = 'use_email' |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
569
diff
changeset
|
44 |
# self.view('editrelation', rset, template=None) |
0 | 45 |
|
46 |
||
47 |
def test_sortable_js_added(self): |
|
48 |
rset = self.execute('EUser X') |
|
49 |
# sortable.js should not be included by default |
|
50 |
self.failIf('jquery.tablesorter.js' in self.view('oneline', rset)) |
|
51 |
# but should be included by the tableview |
|
473 | 52 |
rset = self.execute('Any P,F,S LIMIT 1 WHERE P is EUser, P firstname F, P surname S') |
0 | 53 |
self.failUnless('jquery.tablesorter.js' in self.view('table', rset)) |
54 |
||
55 |
def test_js_added_only_once(self): |
|
56 |
self.vreg.register_vobject_class(SomeView) |
|
57 |
rset = self.execute('EUser X') |
|
58 |
source = self.view('someview', rset).source |
|
59 |
self.assertEquals(source.count('spam.js'), 1) |
|
60 |
||
61 |
||
62 |
||
63 |
class ExplicitViewsTest(WebTest): |
|
64 |
||
65 |
def test_unrelateddivs(self): |
|
66 |
rset = self.execute('Any X WHERE X is EUser, X login "admin"') |
|
67 |
group = self.add_entity('EGroup', name=u'R&D') |
|
68 |
req = self.request(relation='in_group_subject') |
|
69 |
self.view('unrelateddivs', rset, req) |
|
70 |
||
71 |
||
72 |
||
73 |
if __name__ == '__main__': |
|
74 |
from logilab.common.testlib import unittest_main |
|
75 |
unittest_main() |