How to use the runway.cfngin.config.Config function in runway

To help you get started, we’ve selected a few runway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onicagroup / runway / tests / cfngin / test_context.py View on Github external
def test_persistent_graph_location_no_bucket(self):
        """Return an empty dict if key is set but no bucket name."""
        cp_config = self.persist_graph_raw_config.copy()
        cp_config['cfngin_bucket'] = ''

        context = Context(config=Config(cp_config))
        self.assertEqual({}, context.persistent_graph_location)
github onicagroup / runway / tests / cfngin / test_context.py View on Github external
def test_context_default_bucket_name(self):
        """Test context default bucket name."""
        context = Context(config=Config({"namespace": "test"}))
        self.assertEqual(context.bucket_name, "stacker-test")
github onicagroup / runway / tests / cfngin / test_context.py View on Github external
def test_context_bucket_name_is_overridden(self):
        """Test context bucket name is overridden."""
        config = Config({"namespace": "test", "cfngin_bucket": "bucket123"})
        context = Context(config=config)
        self.assertEqual(context.bucket_name, "bucket123")
github onicagroup / runway / tests / cfngin / test_context.py View on Github external
def test_context_tags_with_empty_map(self):
        """Test context tags with empty map."""
        config = Config({"namespace": "test", "tags": {}})
        context = Context(config=config)
        self.assertEqual(context.tags, {})
github onicagroup / runway / tests / cfngin / test_context.py View on Github external
def test_persistent_graph_location_no_json(self):
        """'.json' appended to the key if it does not exist."""
        cp_config = self.persist_graph_raw_config.copy()
        cp_config['persistent_graph_key'] = 'test'

        context = Context(config=Config(cp_config))
        expected = {
            'Bucket': 'cfngin-test',
            'Key': 'persistent_graphs/test/test.json'
        }
        self.assertEqual(expected, context.persistent_graph_location)
github onicagroup / runway / tests / cfngin / test_config.py View on Github external
def test_dump_unicode(self):
        """Test dump unicode."""
        config = Config()
        config.namespace = "test"
        assert dump(config) == b"""namespace: test
stacks: []
"""

        config = Config({"namespace": "test"})
        # Ensure that we're producing standard yaml, that doesn't include
        # python specific objects.
        assert dump(config) != b"namespace: !!python/unicode 'test'\n"
        assert dump(config) == b"""namespace: test
stacks: []
github onicagroup / runway / tests / cfngin / hooks / test_aws_lambda.py View on Github external
def test_path_relative(self):
        """Test path relative."""
        with self.temp_directory_with_files(['test/test.py']) as temp_dir:
            results = self.run_hook(
                functions={'MyFunction': {'path': 'test'}},
                context=Context(config=Config({'namespace': 'test',
                                               'stacker_bucket': 'test'}),
                                config_path=temp_dir.path))

        self.assertIsNotNone(results)

        code = results.get('MyFunction')
        self.assertIsInstance(code, Code)
        self.assert_s3_zip_file_list(code.S3Bucket, code.S3Key, ['test.py'])
github onicagroup / runway / tests / cfngin / test_config.py View on Github external
def test_config_validate_missing_stack_source(self):
        """Test config validate missing stack source."""
        config = Config({
            "namespace": "prod",
            "stacks": [
                {
                    "name": "bastion"}]})
        with self.assertRaises(exceptions.InvalidConfig) as ex:
            config.validate()

        stack_errors = ex.exception.errors['stacks'][0]
        assert stack_errors['template_path'][0].__str__() == \
            "class_path or template_path is required."
        assert stack_errors['class_path'][0].__str__() == \
            "class_path or template_path is required."
github onicagroup / runway / tests / cfngin / test_config.py View on Github external
def test_config_build(self):
        """Test config build."""
        vpc = Stack({"name": "vpc", "class_path": "blueprints.VPC"})
        config = Config({"namespace": "prod", "stacks": [vpc]})
        assert config.namespace == 'prod'
        assert config.stacks[0].name == 'vpc'
        assert config["namespace"] == 'prod'
        config.validate()
github onicagroup / runway / tests / cfngin / test_config.py View on Github external
def test_config_validate_stack_class_and_template_paths(self):
        """Test config validate stack class and template paths."""
        config = Config({
            "namespace": "prod",
            "stacks": [
                {
                    "name": "bastion",
                    "class_path": "foo",
                    "template_path": "bar"}]})
        with self.assertRaises(exceptions.InvalidConfig) as ex:
            config.validate()

        stack_errors = ex.exception.errors['stacks'][0]
        assert stack_errors['template_path'][0].__str__() == \
            "class_path cannot be present when template_path is provided."
        assert stack_errors['class_path'][0].__str__() == \
            "template_path cannot be present when class_path is provided."