コード例 #1
0
    def test_read_with_templated_config_file(self):
        self.context.user_variables = {"variable_key": "user_variable_value"}
        config_reader = ConfigReader(self.context)

        config_reader.templating_vars["stack_group_config"] = {
            "region": "region_region",
            "project_code": "account_project_code",
            "required_version": "'>1.0'",
            "template_bucket_name": "stack_group_template_bucket_name"
        }
        os.environ["TEST_ENV_VAR"] = "environment_variable_value"
        config = config_reader.read(
            "account/stack-group/region/security_groups.yaml"
        )

        assert config == {
            'project_path': self.context.project_path,
            "stack_group_path": "account/stack-group/region",
            "parameters": {
                "param1": "user_variable_value",
                "param2": "environment_variable_value",
                "param3": "region_region",
                "param4": "account_project_code",
                "param5": ">1.0",
                "param6": "stack_group_template_bucket_name"
            }
        }
コード例 #2
0
ファイル: test_config_reader.py プロジェクト: kushalred/AWS
 def test_read_with_empty_config_file(self):
     config_reader = ConfigReader(self.context)
     config = config_reader.read("account/stack-group/region/subnets.yaml")
     assert config == {
         "project_path": self.test_project_path,
         "stack_group_path": "account/stack-group/region"
     }
コード例 #3
0
 def test_read_with_empty_config_file(self):
     config_reader = ConfigReader(self.test_sceptre_directory)
     config = config_reader.read("account/stack-group/region/subnets.yaml")
     assert config == {
         "sceptre_dir": self.test_sceptre_directory,
         "stack_group_path": "account/stack-group/region"
     }
コード例 #4
0
 def test_read_with_templated_config_file(self):
     config_reader = ConfigReader(self.test_project_pathectory,
                                  {"user_variable": "user_variable_value"})
     config_reader.templating_vars["stack_group_config"] = {
         "region": "stack_group_region"
     }
     os.environ["TEST_ENV_VAR"] = "environment_variable_value"
     config = config_reader.read(
         "account/stack-group/region/security_groups.yaml")
     # self.config.read({"user_variable": "user_variable_value"})
     assert config == {
         'project_path': config_reader.project_path,
         "stack_group_path": "account/stack-group/region",
         "parameters": {
             "param1": "user_variable_value",
             "param2": "environment_variable_value",
             "param3": "account",
             "param4": "stack-group",
             "param5": "region",
             "param6": "stack_group_region"
         }
     }
コード例 #5
0
    def test_read_nested_configs(self):
        with self.runner.isolated_filesystem():
            project_path = os.path.abspath('./example')
            config_dir = os.path.join(project_path, "config")
            stack_group_dir_a = os.path.join(config_dir, "A")
            stack_group_dir_b = os.path.join(stack_group_dir_a, "B")
            stack_group_dir_c = os.path.join(stack_group_dir_b, "C")

            os.makedirs(stack_group_dir_c)
            config_filename = "config.yaml"

            config_a = {"keyA": "A", "shared": "A"}
            with open(os.path.join(stack_group_dir_a, config_filename), 'w') as\
                    config_file:
                yaml.safe_dump(config_a,
                               stream=config_file,
                               default_flow_style=False)

            config_b = {"keyB": "B", "parent": "{{ keyA }}", "shared": "B"}
            with open(os.path.join(stack_group_dir_b, config_filename), 'w') as\
                    config_file:
                yaml.safe_dump(config_b,
                               stream=config_file,
                               default_flow_style=False)

            config_c = {"keyC": "C", "parent": "{{ keyB }}", "shared": "C"}
            with open(os.path.join(stack_group_dir_c, config_filename), 'w') as\
                    config_file:
                yaml.safe_dump(config_c,
                               stream=config_file,
                               default_flow_style=False)

            self.context.project_path = project_path
            reader = ConfigReader(self.context)

            config_a = reader.read("A/config.yaml")

            assert config_a == {
                "project_path": project_path,
                "stack_group_path": "A",
                "keyA": "A",
                "shared": "A"
            }

            config_b = reader.read("A/B/config.yaml")

            assert config_b == {
                "project_path": project_path,
                "stack_group_path": "A/B",
                "keyA": "A",
                "keyB": "B",
                "shared": "B",
                "parent": "A"
            }

            config_c = reader.read("A/B/C/config.yaml")

            assert config_c == {
                "project_path": project_path,
                "stack_group_path": "A/B/C",
                "keyA": "A",
                "keyB": "B",
                "keyC": "C",
                "shared": "C",
                "parent": "B"
            }