diff --git a/dotdrop/config.py b/dotdrop/config.py index 656fc4f..487b8c1 100644 --- a/dotdrop/config.py +++ b/dotdrop/config.py @@ -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 diff --git a/tests/test_config.py b/tests/test_config.py index 4b6a406..bbaeb0b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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()