ExpectedResult
- class aws_cdk.integ_tests_alpha.ExpectedResult
Bases:
object
(experimental) Represents the “expected” results to compare.
- Stability:
experimental
- ExampleMetadata:
infused
Example:
# app: App # stack: Stack # queue: sqs.Queue # fn: lambda.IFunction integ = IntegTest(app, "Integ", test_cases=[stack] ) integ.assertions.invoke_function( function_name=fn.function_name, invocation_type=InvocationType.EVENT, payload=JSON.stringify({"status": "OK"}) ) message = integ.assertions.aws_api_call("SQS", "receiveMessage", { "QueueUrl": queue.queue_url, "WaitTimeSeconds": 20 }) message.assert_at_path("Messages.0.Body", ExpectedResult.object_like({ "request_context": { "condition": "Success" }, "request_payload": { "status": "OK" }, "response_context": { "status_code": 200 }, "response_payload": "success" }))
- Stability:
experimental
Attributes
- result
(experimental) The expected results encoded as a string.
- Stability:
experimental
Static Methods
- classmethod array_with(expected)
(experimental) The actual results must be a list and must contain an item with the expected results.
- Parameters:
expected (
Sequence
[Any
]) –- See:
- Stability:
experimental
- Return type:
Example:
# actual results actual = [{ "string_param": "hello" }, { "string_param": "world" } ] # pass ExpectedResult.array_with([{ "string_param": "hello" } ])
- classmethod exact(expected)
(experimental) The actual results must match exactly.
Missing data will result in a failure
- Parameters:
expected (
Any
) –- See:
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-exactpattern
- Stability:
experimental
- Return type:
Example:
# actual results actual = { "string_param": "hello", "number_param": 3, "boolean_param": True } # pass ExpectedResult.exact({ "string_param": "hello", "number_param": 3, "boolean_param": True }) # fail ExpectedResult.exact({ "string_param": "hello" })
- classmethod object_like(expected)
(experimental) The expected results must be a subset of the actual results.
- Parameters:
expected (
Mapping
[str
,Any
]) –- See:
- Stability:
experimental
- Return type:
Example:
# actual results actual = { "string_param": "hello", "number_param": 3, "boolean_param": True, "object_param": {"prop1": "value", "prop2": "value"} } # pass ExpectedResult.object_like({ "string_param": "hello", "object_param": {"prop1": "value"} })
- classmethod string_like_regexp(expected)
(experimental) Actual results is a string that matches the Expected result regex.
- Parameters:
expected (
str
) –- See:
- Stability:
experimental
- Return type:
Example:
# actual results actual = "some string value" # pass ExpectedResult.string_like_regexp("value")