author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 24 Feb 2009 17:13:46 +0100 | |
branch | tls-sprint |
changeset 946 | a130b5ceeca9 |
parent 750 | 89e997bc2bf1 |
child 1263 | 01152fffd593 |
permissions | -rw-r--r-- |
0 | 1 |
import os |
2 |
from tempfile import mktemp |
|
3 |
||
4 |
from logilab.common.testlib import TestCase, unittest_main |
|
5 |
from logilab.common.changelog import Version |
|
6 |
||
7 |
from cubicweb.devtools import ApptestConfiguration |
|
8 |
||
9 |
def unabsolutize(path): |
|
10 |
parts = path.split(os.sep) |
|
515
92d95b86263e
search in reverted order else in case of installed cubes (eg in cubicweb/cubes) we do not remove all expected parts
sylvain.thenault@logilab.fr
parents:
13
diff
changeset
|
11 |
for i, part in reversed(tuple(enumerate(parts))): |
0 | 12 |
if part in ('cubicweb', 'cubes', 'cubes'): |
13 |
return '/'.join(parts[i+1:]) |
|
14 |
raise Exception('duh? %s' % path) |
|
15 |
||
16 |
class CubicWebConfigurationTC(TestCase): |
|
17 |
def setUp(self): |
|
18 |
self.config = ApptestConfiguration('data') |
|
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
19 |
self.config._cubes = ('email', 'file') |
0 | 20 |
|
21 |
def test_reorder_cubes(self): |
|
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
22 |
# jpl depends on email and file and comment |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
23 |
# email depends on file |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
24 |
self.assertEquals(self.config.reorder_cubes(['file', 'email', 'jpl']), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
25 |
('jpl', 'email', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
26 |
self.assertEquals(self.config.reorder_cubes(['email', 'file', 'jpl']), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
27 |
('jpl', 'email', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
28 |
self.assertEquals(self.config.reorder_cubes(['email', 'jpl', 'file']), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
29 |
('jpl', 'email', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
30 |
self.assertEquals(self.config.reorder_cubes(['file', 'jpl', 'email']), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
31 |
('jpl', 'email', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
32 |
self.assertEquals(self.config.reorder_cubes(['jpl', 'file', 'email']), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
33 |
('jpl', 'email', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
34 |
self.assertEquals(self.config.reorder_cubes(('jpl', 'email', 'file')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
35 |
('jpl', 'email', 'file')) |
0 | 36 |
|
37 |
def test_reorder_cubes_recommends(self): |
|
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
38 |
from cubes.comment import __pkginfo__ as comment_pkginfo |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
39 |
comment_pkginfo.__recommend__ = ('file',) |
0 | 40 |
try: |
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
41 |
# email recommends comment |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
42 |
# comment recommends file |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
43 |
self.assertEquals(self.config.reorder_cubes(('jpl', 'email', 'file', 'comment')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
44 |
('jpl', 'email', 'comment', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
45 |
self.assertEquals(self.config.reorder_cubes(('jpl', 'email', 'comment', 'file')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
46 |
('jpl', 'email', 'comment', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
47 |
self.assertEquals(self.config.reorder_cubes(('jpl', 'comment', 'email', 'file')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
48 |
('jpl', 'email', 'comment', 'file')) |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
49 |
self.assertEquals(self.config.reorder_cubes(('comment', 'jpl', 'email', 'file')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
50 |
('jpl', 'email', 'comment', 'file')) |
0 | 51 |
finally: |
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
52 |
comment_pkginfo.__use__ = () |
0 | 53 |
|
54 |
||
55 |
# def test_vc_config(self): |
|
56 |
# vcconf = self.config.vc_config() |
|
57 |
# self.assertIsInstance(vcconf['EEMAIL'], Version) |
|
58 |
# self.assertEquals(vcconf['EEMAIL'], (0, 3, 1)) |
|
59 |
# self.assertEquals(vcconf['CW'], (2, 31, 2)) |
|
60 |
# self.assertRaises(KeyError, vcconf.__getitem__, 'CW_VERSION') |
|
61 |
# self.assertRaises(KeyError, vcconf.__getitem__, 'CRM') |
|
62 |
||
63 |
def test_expand_cubes(self): |
|
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
64 |
self.assertEquals(self.config.expand_cubes(('email', 'eblog')), |
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
65 |
['email', 'eblog', 'file']) |
0 | 66 |
|
67 |
def test_vregistry_path(self): |
|
68 |
self.assertEquals([unabsolutize(p) for p in self.config.vregistry_path()], |
|
69 |
['entities', 'web/views', 'sobjects', |
|
13
bae30087db21
fix unittests in cubicweb/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
70 |
'file/entities.py', 'file/views', 'file/hooks.py', |
750
89e997bc2bf1
update test for new test schema
sylvain.thenault@logilab.fr
parents:
515
diff
changeset
|
71 |
'email/entities.py', 'email/views', 'email/hooks.py', |
89e997bc2bf1
update test for new test schema
sylvain.thenault@logilab.fr
parents:
515
diff
changeset
|
72 |
'test/data/entities.py']) |
0 | 73 |
|
74 |
if __name__ == '__main__': |
|
75 |
unittest_main() |