cubicweb/test/unittest_cwconfig.py
changeset 11929 fcbd6b251d81
parent 11920 f13799fbcfea
parent 11859 2e1a1ebd4730
child 11966 fe995d56c949
equal deleted inserted replaced
11920:f13799fbcfea 11929:fcbd6b251d81
   245         if hasattr(cubes, 'file'):
   245         if hasattr(cubes, 'file'):
   246             del cubes.file
   246             del cubes.file
   247         from cubes import file
   247         from cubes import file
   248         self.assertEqual(file.__path__, [join(self.custom_cubes_dir, 'file')])
   248         self.assertEqual(file.__path__, [join(self.custom_cubes_dir, 'file')])
   249 
   249 
   250     def test_config_value_from_environment(self):
   250     def test_config_value_from_environment_str(self):
   251         self.assertIsNone(self.config['base-url'])
   251         self.assertIsNone(self.config['base-url'])
   252         os.environ['CW_BASE_URL'] = 'https://www.cubicweb.org'
   252         os.environ['CW_BASE_URL'] = 'https://www.cubicweb.org'
   253         try:
   253         try:
   254             self.assertEqual(self.config['base-url'],
   254             self.assertEqual(self.config['base-url'],
   255                              'https://www.cubicweb.org')
   255                              'https://www.cubicweb.org')
   256         finally:
   256         finally:
   257             del os.environ['CW_BASE_URL']
   257             del os.environ['CW_BASE_URL']
   258 
   258 
       
   259     def test_config_value_from_environment_int(self):
       
   260         self.assertEqual(self.config['connections-pool-size'], 4)
       
   261         os.environ['CW_CONNECTIONS_POOL_SIZE'] = '6'
       
   262         try:
       
   263             self.assertEqual(self.config['connections-pool-size'], 6)
       
   264         finally:
       
   265             del os.environ['CW_CONNECTIONS_POOL_SIZE']
       
   266 
       
   267     def test_config_value_from_environment_yn(self):
       
   268         self.assertEqual(self.config['allow-email-login'], False)
       
   269         try:
       
   270             for val, result in (('yes', True), ('no', False),
       
   271                                 ('y', True), ('n', False),):
       
   272                 os.environ['CW_ALLOW_EMAIL_LOGIN'] = val
       
   273             self.assertEqual(self.config['allow-email-login'], result)
       
   274         finally:
       
   275             del os.environ['CW_ALLOW_EMAIL_LOGIN']
       
   276             
   259 
   277 
   260 class FindPrefixTC(unittest.TestCase):
   278 class FindPrefixTC(unittest.TestCase):
   261 
   279 
   262     def make_dirs(self, basedir, *args):
   280     def make_dirs(self, basedir, *args):
   263         path = join(basedir, *args)
   281         path = join(basedir, *args)