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