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 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
def test_config_error(): os.environ["FREELDEP_CONFIG"] = "" os.environ["FREELDEP_HOME"] = "" with pytest.raises(click.UsageError): ConfigParser("")
def test_config_env_2(): os.environ["FREELDEP_CONFIG"] = "./tests/data/config.ini" os.environ["FREELDEP_HOME"] = "" ConfigParser("")
def test_config_env(): os.environ["FREELDEP_CONFIG"] = "" os.environ["FREELDEP_HOME"] = "./freeldep/" ConfigParser("") os.environ["FREELDEP_HOME"] = "./freeldep" ConfigParser("")
def test_config_filename(): os.environ["FREELDEP_CONFIG"] = "" os.environ["FREELDEP_HOME"] = "" ConfigParser("./tests/data/config.ini")
def config(): return ConfigParser("./tests/data/config.ini")