def test_config_get_en(): os.environ["FREELDEP_CONFIG"] = "" os.environ["FREELDEP_HOME"] = "" config = ConfigParser("./tests/data/config.ini") assert config.get("cli", "name", "") == "testcli" assert config.get("cli", "asdasd", "default") == "default" assert config.get("assdasd", "asdasd", "1111") == "1111" assert config.get("aws", "region", "1111") == "region"
class Cli(object): def __init__(self, aws_profile=None, verbose=0, config_file="./cli/config.ini"): logging.basicConfig(format="%(asctime)s - %(message)s", level=self._get_logging_level(verbose)) self.config = ConfigParser(config_file) self.name = self.config.get("cli", "name", "Freeldep") self.version = self.config.get("cli", "version") self.description = self.config.get("cli", "description") self.aws_profile = aws_profile def require_cloud_access(self): if self.aws_profile is None: raise RuntimeError("Please set AWS_PROFILE to deploy resources") def _get_logging_level(self, verbose): if verbose < 1: return logging.WARNING if verbose == 1: return logging.INFO return logging.DEBUG