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_write():
with TemporaryDirectory() as td:
DEFAULT = config.default_config()
config.write_config(DEFAULT, td)
def test_load_config(config0_dir):
with pytest.raises(IOError):
config.load_config('nonexistent')
c = config.load_config(config0_dir)
DEFAULT = config.default_config()
assert c['sync'] != DEFAULT['sync']
assert c['sync']['timeout'] == 60
assert c['sync']['strip_tz'] == DEFAULT['sync']['strip_tz']
assert c['sync']['url'] != DEFAULT['sync']['url']
def check_load_config(config_dir):
convert = False
loaded = config.read_config(config_dir) or {}
if config.detect_old(loaded):
print(
"Found config file with pre-0.7 schema; backing up and converting to new format"
)
convert = True
cfg = config.convert_old(loaded)
else:
cfg = config.default_config()
config.recursive_update(cfg, loaded)
if convert:
config.write_config(cfg, config_dir, backup_existing=True)
return cfg