13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """ |
18 """cubicweb.cwconfig unit tests""" |
19 |
19 |
20 """ |
|
21 import sys |
20 import sys |
22 import os |
21 import os |
23 import tempfile |
22 import tempfile |
24 from os.path import dirname, join, abspath |
23 from os.path import dirname, join, abspath |
25 |
24 |
49 |
48 |
50 def tearDown(self): |
49 def tearDown(self): |
51 ApptestConfiguration.CUBES_PATH = [] |
50 ApptestConfiguration.CUBES_PATH = [] |
52 |
51 |
53 def test_reorder_cubes(self): |
52 def test_reorder_cubes(self): |
54 # jpl depends on email and file and comment |
53 self.config.__class__.CUBES_PATH = [CUSTOM_CUBES_DIR] |
|
54 self.config.adjust_sys_path() |
|
55 # forge depends on email and file and comment |
55 # email depends on file |
56 # email depends on file |
56 self.assertEquals(self.config.reorder_cubes(['file', 'email', 'forge']), |
57 self.assertEquals(self.config.reorder_cubes(['file', 'email', 'forge']), |
57 ('forge', 'email', 'file')) |
58 ('forge', 'email', 'file')) |
58 self.assertEquals(self.config.reorder_cubes(['email', 'file', 'forge']), |
59 self.assertEquals(self.config.reorder_cubes(['email', 'file', 'forge']), |
59 ('forge', 'email', 'file')) |
60 ('forge', 'email', 'file')) |
65 ('forge', 'email', 'file')) |
66 ('forge', 'email', 'file')) |
66 self.assertEquals(self.config.reorder_cubes(('forge', 'email', 'file')), |
67 self.assertEquals(self.config.reorder_cubes(('forge', 'email', 'file')), |
67 ('forge', 'email', 'file')) |
68 ('forge', 'email', 'file')) |
68 |
69 |
69 def test_reorder_cubes_recommends(self): |
70 def test_reorder_cubes_recommends(self): |
|
71 self.config.__class__.CUBES_PATH = [CUSTOM_CUBES_DIR] |
|
72 self.config.adjust_sys_path() |
70 from cubes.comment import __pkginfo__ as comment_pkginfo |
73 from cubes.comment import __pkginfo__ as comment_pkginfo |
71 comment_pkginfo.__recommends_cubes__ = {'file': None} |
74 comment_pkginfo.__recommends_cubes__ = {'file': None} |
72 try: |
75 try: |
73 # email recommends comment |
76 # email recommends comment |
74 # comment recommends file |
77 # comment recommends file |
128 sys.modules.pop('cubes.file', None) |
131 sys.modules.pop('cubes.file', None) |
129 del cubes.file |
132 del cubes.file |
130 from cubes import file |
133 from cubes import file |
131 self.assertEquals(file.__path__, [join(CUSTOM_CUBES_DIR, 'file')]) |
134 self.assertEquals(file.__path__, [join(CUSTOM_CUBES_DIR, 'file')]) |
132 |
135 |
|
136 |
133 class FindPrefixTC(TestCase): |
137 class FindPrefixTC(TestCase): |
134 def make_dirs(self, *args): |
138 def make_dirs(self, *args): |
135 path = join(tempfile.tempdir, *args) |
139 path = join(tempfile.tempdir, *args) |
136 if not os.path.exists(path): |
140 if not os.path.exists(path): |
137 os.makedirs(path) |
141 os.makedirs(path) |