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')
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) eq_(config.get_function_filename(), 'lambda_function.js') open(self.conf_file, 'w').write(NODE43_CONF) config = Config(self.conf_file) eq_(config.get_function_filename(), 'lambda_function.js')
def test_get_runtime(self): config = Config(self.conf_file) eq_(config.get_runtime(), 'python2.7') open(self.conf_file, 'w').write(NODE_CONF) config = Config(self.conf_file) runtime = config.get_configuration().get('runtime') eq_(runtime, 'nodejs4.3') open(self.conf_file, 'w').write(NODE43_CONF) config = Config(self.conf_file) runtime = config.get_configuration().get('runtime') eq_(runtime, 'nodejs4.3')
def test_get_default(self): config = Config(self.conf_file) runtime = config.get_default().get('configuration').get('runtime') eq_(runtime, 'python2.7') subnets = config.get_default().get('configuration').get( 'vpc_config').get('subnets') eq_(subnets, ['subnet-xxxxxxxx'])
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'}]})
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)
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' }, 'secret_files': { 'baz': 'qux' } })
def test_get_default_hook(self): config = Config(self.conf_file) eq_(config.get_default_hook().get('build').get('pre'), []) eq_(config.get_default_hook().get('build').get('post'), [])
def test_get_default_exclude(self): config = Config(self.conf_file) eq_(config.get_default_exclude().pop(), '^\\.test\\.exclude\\.yml$')
def test_get_default_secret(self): config = Config(self.conf_file) eq_(config.get_default_secret().get('key_id'), '<key-id>')
def test_load_raw_secret(self): config = Config(self.conf_file) eq_(config.load_raw_secret().get('test_env'), "{{ env[$$PATH$$] }}")
def test_load_exclude(self): config = Config(self.conf_file) eq_(config.load_exclude().pop(), '^bar')
def test_store_secret_file(self): config = Config(self.conf_file) config.store_secret_file('baz', 'qux') eq_(config.get_secret().get('key_id'), '<key-id>') eq_(config.get_secret().get('secret_files').get('baz'), 'qux')
def test_get_archive_name(self): config = Config(self.conf_file) eq_(config.get_archive_name(), 'test_lambda_function.zip')
def test_get_region(self): config = Config(self.conf_file) eq_(config.get_region(), 'us-east-1') config = Config('/foo/bar') eq_(config.get_region(), None)
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()))
def test_get_namespace(self): config = Config(self.conf_file) eq_(config.get_handler_namespace(), 'lambda_function')
def test_get_vpc_configuration(self): config = Config(self.conf_file) eq_(config.get_vpc_configuration().get('subnets'), ['subnet-xxxxxxxx']) config.get_configuration = Mock(return_value={}) eq_(config.get_vpc_configuration().get('subnets'), [])
def test_get_configuration(self): config = Config(self.conf_file) eq_(config.get_configuration().get('test_env'), os.environ.get('PATH'))
def test_escape(self): config = Config(self.conf_file) eq_(config.escape("{{ foo['bar'] }}"), "'{{ foo[$$bar$$] }}'") eq_(config.escape('{% foo["bar"] %}'), '\'{% foo["bar"] %}\'')
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'})
def test_get_secret_file(self): config = Config(self.conf_file) eq_(config.get_secret_file(), '.test.secret.yml')
def test_get_secret(self): config = Config(self.conf_file) key = config.get_secret().get('key_id') eq_(key, '<key-id>')
def test_get_exclude(self): config = Config(self.conf_file) eq_(config.get_exclude(), ['^bar'])
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')
def test_get_exclude_file(self): config = Config(self.conf_file) eq_(config.get_exclude_file(), '.test.exclude.yml')
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')
def test_get_default_events(self): config = Config(self.conf_file) eq_(config.get_default_events().get('rules').pop().get('name'), 'sample-rule-name')
def test_get_profile(self): config = Config(self.conf_file) eq_(config.get_profile(), 'default')
def test_get_handler_function(self): config = Config(self.conf_file) eq_(config.get_handler_function(), 'lambda_handler')