author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 25 May 2009 16:09:34 +0200 | |
branch | stable |
changeset 1922 | 1a0ddb675951 |
parent 1802 | d628defebc17 |
child 1977 | 606923dff11b |
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 = [ |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
7 |
'Any L,F WHERE E is CWUser, E login L, E firstname F', |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
8 |
'Any L,F,E WHERE E is CWUser, E login L, E firstname F', |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
9 |
'Any COUNT(X) WHERE X is CWUser', |
0 | 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 |
""" |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
18 |
rset = self.execute('CWUser X WHERE X login "admin"') |
0 | 19 |
self.view('copy', rset) |
20 |
||
21 |
||
22 |
||
23 |
class SomeView(AnyRsetView): |
|
24 |
id = 'someview' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
25 |
|
0 | 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): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
36 |
rset = self.execute('Any P,F,S WHERE P is CWUser, P firstname F, P surname S') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
37 |
self.view('table', rset, template=None, displayfilter=True, displaycols=[0,2]) |
0 | 38 |
|
39 |
def test_sortable_js_added(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
40 |
rset = self.execute('CWUser X') |
0 | 41 |
# sortable.js should not be included by default |
42 |
self.failIf('jquery.tablesorter.js' in self.view('oneline', rset)) |
|
43 |
# but should be included by the tableview |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
44 |
rset = self.execute('Any P,F,S LIMIT 1 WHERE P is CWUser, P firstname F, P surname S') |
0 | 45 |
self.failUnless('jquery.tablesorter.js' in self.view('table', rset)) |
46 |
||
47 |
def test_js_added_only_once(self): |
|
1368 | 48 |
self.vreg._loadedmods[__name__] = {} |
0 | 49 |
self.vreg.register_vobject_class(SomeView) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
50 |
rset = self.execute('CWUser X') |
0 | 51 |
source = self.view('someview', rset).source |
52 |
self.assertEquals(source.count('spam.js'), 1) |
|
53 |
||
54 |
||
55 |
||
56 |
class ExplicitViewsTest(WebTest): |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
57 |
|
0 | 58 |
def test_unrelateddivs(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
59 |
rset = self.execute('Any X WHERE X is CWUser, X login "admin"') |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
60 |
group = self.add_entity('CWGroup', name=u'R&D') |
0 | 61 |
req = self.request(relation='in_group_subject') |
62 |
self.view('unrelateddivs', rset, req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
63 |
|
0 | 64 |
|
65 |
if __name__ == '__main__': |
|
66 |
from logilab.common.testlib import unittest_main |
|
67 |
unittest_main() |