Exemplo n.º 1
0
    def test_get_stack_output_clienterror(self, caplog):
        """Test get_stack_output raising ClientError."""
        caplog.set_level(logging.DEBUG, logger="runway.lookups.handlers.cfn")
        client, stubber = setup_cfn_client()
        stack_name = "test-stack"
        query = OutputQuery(stack_name, "output1")

        stubber.add_client_error(
            "describe_stacks",
            service_error_code="ValidationError",
            service_message="Stack %s does not exist" % stack_name,
            expected_params={"StackName": stack_name},
        )

        with stubber, pytest.raises(ClientError):
            assert CfnLookup.get_stack_output(client, query)

        stubber.assert_no_pending_responses()
        assert "describing stack: %s" % stack_name in caplog.messages
Exemplo n.º 2
0
    def test_get_stack_output(self, caplog: LogCaptureFixture) -> None:
        """Test get_stack_output."""
        caplog.set_level(logging.DEBUG, logger="runway.lookups.handlers.cfn")
        client, stubber = setup_cfn_client()
        stack_name = "test-stack"
        outputs = {"output1": "val1", "output2": "val2"}
        query = OutputQuery(stack_name, "output1")

        stubber.add_response(
            "describe_stacks",
            {"Stacks": [generate_describe_stacks_stack(stack_name, outputs)]},
            {"StackName": stack_name},
        )

        with stubber:
            assert CfnLookup.get_stack_output(client, query) == "val1"

        stubber.assert_no_pending_responses()
        assert "describing stack: %s" % stack_name in caplog.messages
        assert ("{} stack outputs: {}".format(stack_name, json.dumps(outputs))
                in caplog.messages)