author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Wed, 05 Aug 2009 09:10:32 +0200 | |
changeset 3385 | 68953ecddd2b |
parent 2657 | de974465d381 |
child 2773 | b2530e3e0afb |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
"""automatic tests |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
""" |
0 | 8 |
|
9 |
from cubicweb.devtools.testlib import WebTest, AutomaticWebTest |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
824
diff
changeset
|
10 |
from cubicweb.view import AnyRsetView |
0 | 11 |
|
12 |
AutomaticWebTest.application_rql = [ |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
13 |
'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
|
14 |
'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
|
15 |
'Any COUNT(X) WHERE X is CWUser', |
0 | 16 |
] |
17 |
||
18 |
class ComposityCopy(WebTest): |
|
19 |
||
20 |
def test_regr_copy_view(self): |
|
21 |
"""regression test: make sure we can ask a copy of a |
|
22 |
composite entity |
|
23 |
""" |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
24 |
rset = self.execute('CWUser X WHERE X login "admin"') |
0 | 25 |
self.view('copy', rset) |
26 |
||
27 |
||
28 |
||
29 |
class SomeView(AnyRsetView): |
|
30 |
id = 'someview' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
31 |
|
0 | 32 |
def call(self): |
33 |
self.req.add_js('spam.js') |
|
34 |
self.req.add_js('spam.js') |
|
35 |
||
36 |
||
37 |
class ManualWebTests(WebTest): |
|
38 |
def setup_database(self): |
|
39 |
self.auto_populate(10) |
|
40 |
||
41 |
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
|
42 |
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
|
43 |
self.view('table', rset, template=None, displayfilter=True, displaycols=[0,2]) |
0 | 44 |
|
45 |
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
|
46 |
rset = self.execute('CWUser X') |
0 | 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 |
|
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('Any P,F,S LIMIT 1 WHERE P is CWUser, 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): |
|
1368 | 54 |
self.vreg._loadedmods[__name__] = {} |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
55 |
self.vreg.register_appobject_class(SomeView) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1368
diff
changeset
|
56 |
rset = self.execute('CWUser X') |
0 | 57 |
source = self.view('someview', rset).source |
58 |
self.assertEquals(source.count('spam.js'), 1) |
|
59 |
||
60 |
||
61 |
||
62 |
class ExplicitViewsTest(WebTest): |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
63 |
|
0 | 64 |
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
|
65 |
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
|
66 |
group = self.add_entity('CWGroup', name=u'R&D') |
0 | 67 |
req = self.request(relation='in_group_subject') |
68 |
self.view('unrelateddivs', rset, req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
69 |
|
0 | 70 |
|
71 |
if __name__ == '__main__': |
|
72 |
from logilab.common.testlib import unittest_main |
|
73 |
unittest_main() |