Example #1
0
 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
Example #2
0
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"
Example #3
0
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
Example #4
0
def test_config_error():
    os.environ["FREELDEP_CONFIG"] = ""
    os.environ["FREELDEP_HOME"] = ""
    with pytest.raises(click.UsageError):
        ConfigParser("")
Example #5
0
def test_config_env_2():
    os.environ["FREELDEP_CONFIG"] = "./tests/data/config.ini"
    os.environ["FREELDEP_HOME"] = ""
    ConfigParser("")
Example #6
0
def test_config_env():
    os.environ["FREELDEP_CONFIG"] = ""
    os.environ["FREELDEP_HOME"] = "./freeldep/"
    ConfigParser("")
    os.environ["FREELDEP_HOME"] = "./freeldep"
    ConfigParser("")
Example #7
0
def test_config_filename():
    os.environ["FREELDEP_CONFIG"] = ""
    os.environ["FREELDEP_HOME"] = ""
    ConfigParser("./tests/data/config.ini")
Example #8
0
def config():
    return ConfigParser("./tests/data/config.ini")