author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Fri, 23 Apr 2010 12:19:54 +0200 | |
branch | stable |
changeset 5389 | 809d3b5b3d31 |
parent 4491 | a0f48c31b58a |
child 5421 | 8167de96c523 |
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 |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2657
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
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 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
9 |
from cubicweb.devtools.testlib import CubicWebTC, AutoPopulateTest, 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 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
18 |
class ComposityCopy(CubicWebTC): |
0 | 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): |
|
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
30 |
__regid__ = '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): |
3474
020fc867f7b2
[api] use _cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3408
diff
changeset
|
33 |
self._cw.add_js('spam.js') |
020fc867f7b2
[api] use _cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3408
diff
changeset
|
34 |
self._cw.add_js('spam.js') |
0 | 35 |
|
36 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
37 |
class ManualCubicWebTCs(AutoPopulateTest): |
0 | 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__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
55 |
self.vreg.register(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 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
62 |
class ExplicitViewsTest(CubicWebTC): |
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"') |
4087 | 66 |
group = self.request().create_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() |