def test_set_uses_default(self): """ Ensure uses function 'default' argument if no env or preset value """ conf = Config() conf.set('foo', 1234) self.assertEqual(conf.foo, 1234)
def test_set_no_eval(self): """ Ensure that if the 'default' is a string, won't evaluate env variable """ conf = Config() with patch('cadasta.workertoolbox.conf.env', {'CELERY_FOO': 'False'}): conf.set('foo', 'True') self.assertEqual(conf.foo, 'False')
def test_set_no_overwrite(self): """ Ensure that sets to provide init keyword argument instead of env variable or function 'default' argument """ conf = Config(foo=1234) conf.set('foo', 5678) self.assertEqual(conf.foo, 1234)
def test_set_bad_env_val(self): """ Ensure error is thrown if the 'default' is a string, and env variable is not evaluatable value """ conf = Config() with patch('cadasta.workertoolbox.conf.env', {'CELERY_FOO': ''}): with self.assertRaises(ValueError): conf.set('foo', True)