Esempio n. 1
0
 def test_config_is_loaded(self, tmpdir):
     path = str(tmpdir)
     config_path = os.path.join(path, '.chacractl')
     util.default_config_path = lambda: config_path
     util.ensure_default_config()
     module = util.load_config()
     assert module.user == 'chacra user'
     assert module.key == 'secret'
Esempio n. 2
0
 def test_config_has_some_defaults(self, tmpdir):
     path = str(tmpdir)
     config_path = os.path.join(path, '.chacractl')
     util.default_config_path = lambda: config_path
     util.ensure_default_config()
     msg = "This file was automatically generated"
     with open(config_path, 'r') as f:
         assert msg in f.read()
Esempio n. 3
0
 def test_config_will_not_overwrite(self, tmpdir):
     path = str(tmpdir)
     config_path = os.path.join(path, '.chacractl')
     with open(config_path, 'w') as f:
         f.write('')
     util.default_config_path = lambda: config_path
     util.ensure_default_config()
     with open(config_path, 'r') as f:
         assert f.read() == ''
Esempio n. 4
0
 def api_credentials(self):
     util.ensure_default_config()
     user, key = os.environ.get("CHACRA_USER"), os.environ.get("CHACRA_KEY")
     if not user or not key:
         # check for the config file
         conf_module = util.load_config()
         user, key = conf_module.user, conf_module.key
     chacractl.config["credentials"] = (user, key)
     chacractl.config["url"] = conf_module.url
Esempio n. 5
0
 def api_credentials(self):
     util.ensure_default_config()
     user, key = os.environ.get('CHACRA_USER'), os.environ.get('CHACRA_KEY')
     if not user or not key:
         # check for the config file
         conf_module = util.load_config()
         user, key = conf_module.user, conf_module.key
     chacractl.config['credentials'] = (user, key)
     chacractl.config['url'] = conf_module.url
     chacractl.config['ssl_verify'] = getattr(conf_module, 'ssl_verify', True)
Esempio n. 6
0
 def api_credentials(self):
     util.ensure_default_config()
     user, key = os.environ.get('CHACRA_USER'), os.environ.get('CHACRA_KEY')
     if not user or not key:
         # check for the config file
         conf_module = util.load_config()
         user, key = conf_module.user, conf_module.key
     chacractl.config['credentials'] = (user, key)
     chacractl.config['url'] = conf_module.url
     chacractl.config['ssl_verify'] = getattr(conf_module, 'ssl_verify',
                                              True)
Esempio n. 7
0
 def test_create_config(self, tmpdir):
     path = str(tmpdir)
     config_path = os.path.join(path, '.chacractl')
     util.default_config_path = lambda: config_path
     util.ensure_default_config()
     assert os.path.exists(config_path)