Пример #1
0
    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
0
    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')
Пример #3
0
    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')
Пример #4
0
 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'])
Пример #5
0
 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
0
    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)
Пример #7
0
 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'
             }
         })
Пример #8
0
 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'), [])
Пример #9
0
 def test_get_default_exclude(self):
     config = Config(self.conf_file)
     eq_(config.get_default_exclude().pop(), '^\\.test\\.exclude\\.yml$')
Пример #10
0
 def test_get_default_secret(self):
     config = Config(self.conf_file)
     eq_(config.get_default_secret().get('key_id'), '<key-id>')
Пример #11
0
 def test_load_raw_secret(self):
     config = Config(self.conf_file)
     eq_(config.load_raw_secret().get('test_env'), "{{ env[$$PATH$$] }}")
Пример #12
0
 def test_load_exclude(self):
     config = Config(self.conf_file)
     eq_(config.load_exclude().pop(), '^bar')
Пример #13
0
 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')
Пример #14
0
 def test_get_archive_name(self):
     config = Config(self.conf_file)
     eq_(config.get_archive_name(), 'test_lambda_function.zip')
Пример #15
0
 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)
Пример #16
0
 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()))
Пример #17
0
 def test_get_namespace(self):
     config = Config(self.conf_file)
     eq_(config.get_handler_namespace(), 'lambda_function')
Пример #18
0
 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'), [])
Пример #19
0
 def test_get_configuration(self):
     config = Config(self.conf_file)
     eq_(config.get_configuration().get('test_env'), os.environ.get('PATH'))
Пример #20
0
 def test_escape(self):
     config = Config(self.conf_file)
     eq_(config.escape("{{ foo['bar'] }}"), "'{{ foo[$$bar$$] }}'")
     eq_(config.escape('{% foo["bar"] %}'), '\'{% foo["bar"] %}\'')
Пример #21
0
 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'})
Пример #22
0
 def test_get_secret_file(self):
     config = Config(self.conf_file)
     eq_(config.get_secret_file(), '.test.secret.yml')
Пример #23
0
 def test_get_secret(self):
     config = Config(self.conf_file)
     key = config.get_secret().get('key_id')
     eq_(key, '<key-id>')
Пример #24
0
 def test_get_exclude(self):
     config = Config(self.conf_file)
     eq_(config.get_exclude(), ['^bar'])
Пример #25
0
 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')
Пример #26
0
 def test_get_exclude_file(self):
     config = Config(self.conf_file)
     eq_(config.get_exclude_file(), '.test.exclude.yml')
Пример #27
0
 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')
Пример #28
0
 def test_get_default_events(self):
     config = Config(self.conf_file)
     eq_(config.get_default_events().get('rules').pop().get('name'),
         'sample-rule-name')
Пример #29
0
 def test_get_profile(self):
     config = Config(self.conf_file)
     eq_(config.get_profile(), 'default')
Пример #30
0
 def test_get_handler_function(self):
     config = Config(self.conf_file)
     eq_(config.get_handler_function(), 'lambda_handler')