Beispiel #1
0
    def test_resolve_with_implicit_stack_reference(self,
                                                   mock_get_output_value):
        stack = MagicMock(spec=Stack)
        stack.dependencies = []
        stack.project_code = "project-code"
        stack.name = "account/dev/stack"
        stack._connection_manager = MagicMock(spec=ConnectionManager)

        dependency = MagicMock()
        dependency.name = "account/dev/vpc"
        dependency.profile = 'dependency_profile'
        dependency.region = 'dependency_region'

        mock_get_output_value.return_value = "output_value"

        stack_output_resolver = StackOutput("account/dev/vpc.yaml::VpcId",
                                            stack)

        stack_output_resolver.setup()
        assert stack.dependencies == ["account/dev/vpc.yaml"]

        stack.dependencies = [dependency]
        result = stack_output_resolver.resolve()
        assert result == "output_value"
        mock_get_output_value.assert_called_once_with(
            "project-code-account-dev-vpc",
            "VpcId",
            profile='dependency_profile',
            region='dependency_region')
Beispiel #2
0
    def test_resolver_with_existing_dependencies(self, mock_get_output_value):
        stack = MagicMock(spec=Stack)
        stack.dependencies = ["existing"]
        stack.project_code = "project-code"
        stack.template.connection_manager = MagicMock(spec=ConnectionManager)

        dependency = MagicMock()
        dependency.name = "account/dev/vpc"
        dependency.profile = 'dependency_profile'
        dependency.region = 'dependency_region'

        mock_get_output_value.return_value = "output_value"

        stack_output_resolver = StackOutput("account/dev/vpc::VpcId", stack)

        stack_output_resolver.setup()
        assert stack.dependencies == ["existing", "account/dev/vpc"]

        stack.dependencies = [MagicMock(), dependency]
        result = stack_output_resolver.resolve()
        assert result == "output_value"
        mock_get_output_value.assert_called_once_with(
            "project-code-account-dev-vpc",
            "VpcId",
            profile='dependency_profile',
            region='dependency_region')
Beispiel #3
0
    def test_resolve_with_implicit_stack_reference_top_level(
            self, mock_get_output_value):
        stack = MagicMock(spec=Stack)
        stack.dependencies = []
        stack.project_code = "project-code"
        stack.name = "stack"
        stack._connection_manager = MagicMock(spec=ConnectionManager)

        dependency = MagicMock()
        dependency.project_code = "meh"
        dependency.name = "vpc"
        dependency.profile = "dependency_profile"
        dependency.region = "dependency_region"
        dependency.iam_role = "dependency_iam_role"

        mock_get_output_value.return_value = "output_value"

        stack_output_resolver = StackOutput("vpc.yaml::VpcId", stack)

        stack_output_resolver.setup()
        assert stack.dependencies == ["vpc.yaml"]

        stack.dependencies = [dependency]
        result = stack_output_resolver.resolve()
        assert result == "output_value"
        mock_get_output_value.assert_called_once_with(
            "meh-vpc",
            "VpcId",
            profile="dependency_profile",
            region="dependency_region",
            iam_role="dependency_iam_role")
Beispiel #4
0
 def test_resolver(self, mock_get_output_value):
     stack = MagicMock(spec=Stack)
     stack.dependencies = []
     stack.project_code = "project-code"
     stack.connection_manager = MagicMock(spec=ConnectionManager)
     stack_output_resolver = StackOutput("account/dev/vpc::VpcId", stack)
     mock_get_output_value.return_value = "output_value"
     stack_output_resolver.setup()
     result = stack_output_resolver.resolve()
     assert result == "output_value"
     mock_get_output_value.assert_called_once_with(
         "project-code-account-dev-vpc", "VpcId")
     assert stack.dependencies == ["account/dev/vpc"]