author | Florent <florent@secondweb.fr> |
Mon, 27 Apr 2009 19:01:00 +0200 | |
branch | tls-sprint |
changeset 1488 | 6da89a703c5a |
parent 1398 | 5fe84a5f7035 |
child 1802 | d628defebc17 |
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' |
|
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): |
|
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') |
1087 | 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): |
|
57 |
||
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) |
|
63 |
||
64 |
||
65 |
||
66 |
if __name__ == '__main__': |
|
67 |
from logilab.common.testlib import unittest_main |
|
68 |
unittest_main() |