test/unittest_cwconfig.py
branchtls-sprint
changeset 1640 65b60f177eb1
parent 1341 9502d02630bf
child 1977 606923dff11b
equal deleted inserted replaced
1639:375c857aa0f5 1640:65b60f177eb1
    12     parts = path.split(os.sep)
    12     parts = path.split(os.sep)
    13     for i, part in reversed(tuple(enumerate(parts))):
    13     for i, part in reversed(tuple(enumerate(parts))):
    14         if part.startswith('cubicweb') or part == 'cubes':
    14         if part.startswith('cubicweb') or part == 'cubes':
    15             return '/'.join(parts[i+1:])
    15             return '/'.join(parts[i+1:])
    16     raise Exception('duh? %s' % path)
    16     raise Exception('duh? %s' % path)
    17     
    17 
    18 class CubicWebConfigurationTC(TestCase):
    18 class CubicWebConfigurationTC(TestCase):
    19     def setUp(self):
    19     def setUp(self):
    20         self.config = ApptestConfiguration('data')
    20         self.config = ApptestConfiguration('data')
    21         self.config._cubes = ('email', 'file')
    21         self.config._cubes = ('email', 'file')
    22 
    22 
    36                           ('jpl', 'email', 'file'))
    36                           ('jpl', 'email', 'file'))
    37         self.assertEquals(self.config.reorder_cubes(['jpl', 'file', 'email']),
    37         self.assertEquals(self.config.reorder_cubes(['jpl', 'file', 'email']),
    38                           ('jpl', 'email', 'file'))
    38                           ('jpl', 'email', 'file'))
    39         self.assertEquals(self.config.reorder_cubes(('jpl', 'email', 'file')),
    39         self.assertEquals(self.config.reorder_cubes(('jpl', 'email', 'file')),
    40                           ('jpl', 'email', 'file'))
    40                           ('jpl', 'email', 'file'))
    41         
    41 
    42     def test_reorder_cubes_recommends(self):
    42     def test_reorder_cubes_recommends(self):
    43         from cubes.comment import __pkginfo__ as comment_pkginfo
    43         from cubes.comment import __pkginfo__ as comment_pkginfo
    44         comment_pkginfo.__recommend__ = ('file',)
    44         comment_pkginfo.__recommend__ = ('file',)
    45         try:
    45         try:
    46             # email recommends comment
    46             # email recommends comment
    53                               ('jpl', 'email', 'comment', 'file'))
    53                               ('jpl', 'email', 'comment', 'file'))
    54             self.assertEquals(self.config.reorder_cubes(('comment', 'jpl', 'email', 'file')),
    54             self.assertEquals(self.config.reorder_cubes(('comment', 'jpl', 'email', 'file')),
    55                               ('jpl', 'email', 'comment', 'file'))
    55                               ('jpl', 'email', 'comment', 'file'))
    56         finally:
    56         finally:
    57             comment_pkginfo.__use__ = ()
    57             comment_pkginfo.__use__ = ()
    58             
    58 
    59         
    59 
    60 #     def test_vc_config(self):
    60 #     def test_vc_config(self):
    61 #         vcconf = self.config.vc_config()
    61 #         vcconf = self.config.vc_config()
    62 #         self.assertIsInstance(vcconf['EEMAIL'], Version)
    62 #         self.assertIsInstance(vcconf['EEMAIL'], Version)
    63 #         self.assertEquals(vcconf['EEMAIL'], (0, 3, 1))
    63 #         self.assertEquals(vcconf['EEMAIL'], (0, 3, 1))
    64 #         self.assertEquals(vcconf['CW'], (2, 31, 2))
    64 #         self.assertEquals(vcconf['CW'], (2, 31, 2))
    65 #         self.assertRaises(KeyError, vcconf.__getitem__, 'CW_VERSION')
    65 #         self.assertRaises(KeyError, vcconf.__getitem__, 'CW_VERSION')
    66 #         self.assertRaises(KeyError, vcconf.__getitem__, 'CRM')
    66 #         self.assertRaises(KeyError, vcconf.__getitem__, 'CRM')
    67         
    67 
    68     def test_expand_cubes(self):
    68     def test_expand_cubes(self):
    69         self.assertEquals(self.config.expand_cubes(('email', 'eblog')),
    69         self.assertEquals(self.config.expand_cubes(('email', 'eblog')),
    70                           ['email', 'eblog', 'file'])
    70                           ['email', 'eblog', 'file'])
    71 
    71 
    72     def test_vregistry_path(self):
    72     def test_vregistry_path(self):
   102         # file cube should be overriden by the one found in data/cubes
   102         # file cube should be overriden by the one found in data/cubes
   103         sys.modules.pop('cubes.file', None)
   103         sys.modules.pop('cubes.file', None)
   104         del cubes.file
   104         del cubes.file
   105         from cubes import file
   105         from cubes import file
   106         self.assertEquals(file.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'file'))])
   106         self.assertEquals(file.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'file'))])
   107                                        
   107 
   108                           
   108 
   109 if __name__ == '__main__':
   109 if __name__ == '__main__':
   110     unittest_main()
   110     unittest_main()