本文整理汇总了Python中lamvery.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_function_filename
def test_get_function_filename(self):
config = Config(self.conf_file)
eq_(config.get_function_filename(), 'lambda_function.py')
open(self.conf_file, 'w').write(NODE_CONF)
config = Config(self.conf_file)
runtime = config.get_configuration().get('runtime')
eq_(runtime, 'nodejs')
eq_(config.get_function_filename(), 'lambda_function.js')
示例2: test_generate_lambda_secret
def test_generate_lambda_secret(self):
config = Config(self.conf_file)
secret = config.generate_lambda_secret()
eq_(secret, {
'region': 'us-east-1',
'cipher_texts': {
'foo': 'bar'
}
})
示例3: __init__
class BaseAction:
__metaclass__ = ABCMeta
_logger = None
def __init__(self, args):
self._config = Config(args.conf_file)
self._dry_run = False
logger_name = 'lamvery'
if hasattr(args, 'dry_run'):
self._dry_run = args.dry_run
if self._dry_run:
logger_name = '(Dry run) lamvery'
self._logger = get_logger(logger_name)
@abstractmethod
def action(self):
raise NotImplementedError
def _get_client(self, cls):
return cls(
region=self._config.get_region(),
profile=self._config.get_profile(),
dry_run=self._dry_run)
def get_lambda_client(self):
return self._get_client(LambdaClient)
def get_kms_client(self):
return self._get_client(KmsClient)
def get_events_client(self):
return self._get_client(EventsClient)
def get_logs_client(self):
return self._get_client(LogsClient)
def _get_diff(self, remote, local, keys):
diff = {}
for k in keys:
r = remote.get(k[0])
l = local.get(k[1])
if r == l:
diff[k[1]] = None
else:
diff[k[1]] = (r, l,)
return diff
def _print_diff(self, prefix, remote, local, keys):
diff = self._get_diff(remote, local, keys)
for k, v in diff.items():
if v is not None:
self._logger.warn(
'{p} {k}: {r} -> {l}'.format(p=prefix, k=k, r=v[0], l=v[1]))
示例4: __init__
def __init__(self, args):
self._config = Config(args.conf_file)
self._dry_run = False
logger_name = 'lamvery'
if hasattr(args, 'dry_run'):
self._dry_run = args.dry_run
if self._dry_run:
logger_name = '(Dry run) lamvery'
self._logger = get_logger(logger_name)
示例5: test_get_events
def test_get_events(self):
config = Config(self.conf_file)
eq_(config.get_events().get('rules').pop().get('schedule'), 'rate(5 minutes)')
config.load_events = Mock(return_value=None)
eq_(config.get_events(), {'rules': []})
config.load_events = Mock(return_value=[{'rule': 'foo'}])
eq_(config.get_events(), {'rules': [{'rule': 'foo', 'name': 'foo'}]})
示例6: test_get_default_exclude
def test_get_default_exclude(self):
config = Config(self.conf_file)
eq_(config.get_default_exclude().pop(), '^\\.test\\.exclude\\.yml$')
示例7: get_default_secret
def get_default_secret(self):
config = Config(self.conf_file)
eq_(
config.get_default_secret().get('key_id').get('<key-id>'),
'sample-rule-name')
示例8: test_get_default_events
def test_get_default_events(self):
config = Config(self.conf_file)
eq_(
config.get_default_events().pop().get('rule'),
'sample-rule-name')
示例9: test_get_default
def test_get_default(self):
config = Config(self.conf_file)
runtime = config.get_default().get('configuration').get('runtime')
eq_(runtime, 'python2.7')
示例10: test_save_api_id
def test_save_api_id(self):
config = Config(self.conf_file)
config.save_api_id('foo')
eq_(config.get_api_id(), 'foo')
eq_(config.get_api_stage(), 'dev')
示例11: test_get_secret_file
def test_get_secret_file(self):
config = Config(self.conf_file)
eq_(config.get_secret_file(), '.test.secret.yml')
示例12: test_get_exclude_file
def test_get_exclude_file(self):
config = Config(self.conf_file)
eq_(config.get_exclude_file(), '.test.exclude.yml')
示例13: test_get_default_api
def test_get_default_api(self):
config = Config(self.conf_file)
eq_(config.get_default_api().get('api_id'), '<your-rest-api-id>')
eq_(
config.get_default_api().get('configuration').get('info'),
{'title': 'Sample API'})
示例14: test_store_secret
def test_store_secret(self):
config = Config(self.conf_file)
config.store_secret('foo', 'bar')
eq_(config.get_secret().get('key_id'), '<key-id>')
eq_(config.get_secret().get('cipher_texts').get('foo'), 'bar')
示例15: test_get_function_name
def test_get_function_name(self):
config = Config(self.conf_file)
eq_(config.get_function_name(), 'test_lambda_function')
config = Config('/foo/bar')
eq_(config.get_function_name(), os.path.basename(os.getcwd()))