def test_config_invalidate(): """ Make sure a bad validation breaks """ obj = load_config('profiles', 'test_profile_bad') try: validate_object('config', obj, "profiles/test_profile_bad") assert True is False except InvalidConfigError as e: assert e.config_name == "profiles/test_profile_bad"
def get_config(self, name): """ See :meth:`dput.config.AbstractConfig.get_config` """ logger.trace("Loading entry %s" % (name)) ret = self.defaults.copy() for config in self.configs: obj = config.get_config(name) logger.trace(obj) ret.update(obj) ret = _config_cleanup(ret) logger.trace('Rewrote to:') logger.trace(obj) if logger.isEnabledFor(logging.DEBUG): logger.debug("Got configuration: %s" % (name)) for key in ret: logger.debug("\t%s: %s" % (key, ret[key])) validate_object('config', ret, 'profiles/%s' % (name)) return ret
def get_hooks(profile): for hook in profile['hooks']: conf = load_config('hooks', hook) validate_object('plugin', conf, 'hooks/%s' % (hook)) yield (hook, conf)
def test_config_validate(): """ Make sure we can validate a good config """ obj = load_config('profiles', 'test_profile') validate_object('config', obj, "profiles/test_profile")