IDeployAssert

class aws_cdk.integ_tests.IDeployAssert(*args, **kwds)

Bases: Protocol

(experimental) Interface that allows for registering a list of assertions that should be performed on a construct.

This is only necessary when writing integration tests.

Stability:

experimental

Methods

aws_api_call(service, api, parameters=None)

(experimental) Query AWS using JavaScript SDK V2 API calls.

This can be used to either trigger an action or to return a result that can then be asserted against an expected value

Parameters:
  • service (str) –

  • api (str) –

  • parameters (Optional[Any]) –

Stability:

experimental

Return type:

IAwsApiCall

Example:

# app: App
# integ: IntegTest

integ.assertions.aws_api_call("SQS", "sendMessage", {
    "QueueUrl": "url",
    "MessageBody": "hello"
})
message = integ.assertions.aws_api_call("SQS", "receiveMessage", {
    "QueueUrl": "url"
})
message.expect(ExpectedResult.object_like({
    "Messages": [{"Body": "hello"}]
}))
expect(id, expected, actual)

(experimental) Assert that the ExpectedResult is equal to the ActualResult.

Parameters:
Stability:

experimental

Return type:

None

Example:

# integ: IntegTest
# api_call: AwsApiCall

integ.assertions.expect("invoke",
    ExpectedResult.object_like({"Payload": "OK"}),
    ActualResult.from_aws_api_call(api_call, "Body"))
invoke_function(*, function_name, invocation_type=None, log_type=None, payload=None)

(experimental) Invoke a lambda function and return the response which can be asserted.

Parameters:
  • function_name (str) – (experimental) The name of the function to invoke.

  • invocation_type (Optional[InvocationType]) – (experimental) The type of invocation to use. Default: InvocationType.REQUEST_RESPONE

  • log_type (Optional[LogType]) – (experimental) Whether to return the logs as part of the response. Default: LogType.NONE

  • payload (Optional[str]) – (experimental) Payload to send as part of the invoke. Default: - no payload

Stability:

experimental

Return type:

IAwsApiCall

Example:

# app: App
# integ: IntegTest

invoke = integ.assertions.invoke_function(
    function_name="my-function"
)
invoke.expect(ExpectedResult.object_like({
    "Payload": "200"
}))