mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 14:31:46 +00:00
handle not existing included profile
This commit is contained in:
@@ -155,6 +155,9 @@ class Cfg:
|
||||
if not self.profiles[profile][self.key_profiles_incl]:
|
||||
return included
|
||||
for other in self.profiles[profile][self.key_profiles_incl]:
|
||||
if other not in self.prodots:
|
||||
self.log.warn('unknown included profile \"%s\"' % (other))
|
||||
continue
|
||||
included.extend(self.prodots[other])
|
||||
return included
|
||||
|
||||
|
||||
@@ -79,9 +79,6 @@ class TestConfig(unittest.TestCase):
|
||||
pf2key: {'dotfiles': [df1key]}
|
||||
}
|
||||
|
||||
print(content)
|
||||
print(content['profiles'])
|
||||
|
||||
# save the new config
|
||||
with open(confpath, 'w') as f:
|
||||
yaml.dump(content, f, default_flow_style=False, indent=2)
|
||||
@@ -105,6 +102,23 @@ class TestConfig(unittest.TestCase):
|
||||
self.assertTrue(df1key in [x.key for x in dotfiles])
|
||||
self.assertFalse(df2key in [x.key for x in dotfiles])
|
||||
|
||||
# test not existing included profile
|
||||
# edit the config
|
||||
with open(confpath, 'r') as f:
|
||||
content = yaml.load(f)
|
||||
content['profiles'] = {
|
||||
pf1key: {'dotfiles': [df2key], 'include': ['host2']},
|
||||
pf2key: {'dotfiles': [df1key], 'include': ['host3']}
|
||||
}
|
||||
|
||||
# save the new config
|
||||
with open(confpath, 'w') as f:
|
||||
yaml.dump(content, f, default_flow_style=False, indent=2)
|
||||
|
||||
# do the tests
|
||||
conf = Cfg(confpath)
|
||||
self.assertTrue(conf is not None)
|
||||
|
||||
|
||||
def main():
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user