Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_config_filenames_with_XDG_vars_set(self):
setenv('XDG_CONFIG_HOME', '/myhome/mindy')
setenv('XDG_CONFIG_DIRS', '/tmp/etc:/usr/local/etc')
cfn = debops.config._get_config_filenames()
self.assertListEqual(cfn,
['/etc/debops.cfg',
'/usr/local/etc/debops.cfg',
'/tmp/etc/debops.cfg',
'/myhome/mindy/debops.cfg'])
def test_get_config_filenames_with_XDG_CONFIG_HOME_set(self):
setenv('XDG_CONFIG_HOME', '/myhome/mindy')
unsetenv('XDG_CONFIG_DIRS')
cfn = debops.config._get_config_filenames()
self.assertListEqual(cfn,
['/etc/debops.cfg',
'/etc/xdg/debops.cfg',
'/myhome/mindy/debops.cfg'])
def test_get_config_filenames_with_XDG_CONFIG_DIRS_set(self):
unsetenv('XDG_CONFIG_HOME')
setenv('XDG_CONFIG_DIRS', '/tmp/mindy:/tmp/etc:/usr/local/etc')
cfn = debops.config._get_config_filenames()
self.assertListEqual(cfn,
['/etc/debops.cfg',
'/usr/local/etc/debops.cfg',
'/tmp/etc/debops.cfg',
'/tmp/mindy/debops.cfg',
os.path.expanduser('~/.config/debops.cfg')])
def _read_config(self, project_dir):
# refresh debops._configfiles with set environment
cfn = debops.config._get_config_filenames()
cfn.remove('/etc/debops.cfg')
debops.config._configfiles = cfn
cfg = debops.config.read_config(project_dir)
del cfg['paths']
return cfg
def _read_config(self, project_dir):
# refresh debops._configfiles with set environment
cfn = debops.config._get_config_filenames()
cfn.remove('/etc/debops.cfg')
debops.config._configfiles = cfn
return debops.config.read_config(project_dir)
def test_get_config_filenames_no_env(self):
unsetenv('XDG_CONFIG_HOME')
unsetenv('XDG_CONFIG_DIRS')
cfn = debops.config._get_config_filenames()
self.assertListEqual(cfn,
['/etc/debops.cfg',
'/etc/xdg/debops.cfg',
os.path.expanduser('~/.config/debops.cfg')])
def _read_config(self, project_dir):
# refresh debops._configfiles with set environment
cfn = debops.config._get_config_filenames()
cfn.remove('/etc/debops.cfg')
debops.config._configfiles = cfn
cfg = debops.config.read_config(project_dir)
del cfg['paths']
return cfg
def _read_config(self, project_dir):
# refresh debops._configfiles with set environment
cfn = debops.config._get_config_filenames()
cfn.remove('/etc/debops.cfg')
debops.config._configfiles = cfn
return debops.config.read_config(project_dir)
def test_defaults_linux(self):
sys.platform = 'linux2'
reload(debops.config)
cfgparser = ConfigParser.SafeConfigParser()
cfgparser.readfp(cStringIO.StringIO(debops.config.DEFAULTS))
self.assertEqual(cfgparser.get('paths', 'data-home'),
'$XDG_DATA_HOME/debops')
def setUp(self):
self.sandbox = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.sandbox)
self._saved_configfiles = debops.config._configfiles[:]
# remove '/etc/debobs.cfg' to make results predictable
debops.config._configfiles.remove('/etc/debops.cfg')