|
13 | 13 | from __future__ import absolute_import
|
14 | 14 |
|
15 | 15 | import boto3
|
| 16 | +import pytest |
16 | 17 |
|
17 | 18 | from unittest.mock import patch
|
18 | 19 | from stepfunctions.steps.service import DynamoDBGetItemStep, DynamoDBPutItemStep, DynamoDBUpdateItemStep, DynamoDBDeleteItemStep
|
|
30 | 31 | from stepfunctions.steps.service import EventBridgePutEventsStep
|
31 | 32 | from stepfunctions.steps.service import SnsPublishStep, SqsSendMessageStep
|
32 | 33 | from stepfunctions.steps.service import GlueDataBrewStartJobRunStep
|
| 34 | +from stepfunctions.steps.service import StepFunctionsStartExecutionStep |
| 35 | +from stepfunctions.steps.integration_resources import IntegrationPattern |
33 | 36 |
|
34 | 37 |
|
35 | 38 | @patch.object(boto3.session.Session, 'region_name', 'us-east-1')
|
@@ -1158,3 +1161,97 @@ def test_eks_call_step_creation():
|
1158 | 1161 | },
|
1159 | 1162 | 'End': True
|
1160 | 1163 | }
|
| 1164 | + |
| 1165 | + |
| 1166 | +@patch.object(boto3.session.Session, 'region_name', 'us-east-1') |
| 1167 | +def test_step_functions_start_execution_step_creation_default(): |
| 1168 | + step = StepFunctionsStartExecutionStep( |
| 1169 | + "SFN Start Execution", parameters={ |
| 1170 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1171 | + "Name": "ExecutionName" |
| 1172 | + }) |
| 1173 | + |
| 1174 | + assert step.to_dict() == { |
| 1175 | + "Type": "Task", |
| 1176 | + "Resource": "arn:aws:states:::states:startExecution.sync:2", |
| 1177 | + "Parameters": { |
| 1178 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1179 | + "Name": "ExecutionName" |
| 1180 | + }, |
| 1181 | + "End": True |
| 1182 | + } |
| 1183 | + |
| 1184 | + |
| 1185 | +@patch.object(boto3.session.Session, 'region_name', 'us-east-1') |
| 1186 | +def test_step_functions_start_execution_step_creation_call_and_continue(): |
| 1187 | + step = StepFunctionsStartExecutionStep( |
| 1188 | + "SFN Start Execution", integration_pattern=IntegrationPattern.CallAndContinue, parameters={ |
| 1189 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1190 | + "Name": "ExecutionName" |
| 1191 | + }) |
| 1192 | + |
| 1193 | + assert step.to_dict() == { |
| 1194 | + "Type": "Task", |
| 1195 | + "Resource": "arn:aws:states:::states:startExecution", |
| 1196 | + "Parameters": { |
| 1197 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1198 | + "Name": "ExecutionName" |
| 1199 | + }, |
| 1200 | + "End": True |
| 1201 | + } |
| 1202 | + |
| 1203 | + |
| 1204 | +@patch.object(boto3.session.Session, 'region_name', 'us-east-1') |
| 1205 | +def test_step_functions_start_execution_step_creation_wait_for_completion(): |
| 1206 | + step = StepFunctionsStartExecutionStep( |
| 1207 | + "SFN Start Execution - Sync", integration_pattern=IntegrationPattern.WaitForCompletion, parameters={ |
| 1208 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1209 | + "Name": "ExecutionName" |
| 1210 | + }) |
| 1211 | + |
| 1212 | + assert step.to_dict() == { |
| 1213 | + "Type": "Task", |
| 1214 | + "Resource": "arn:aws:states:::states:startExecution.sync:2", |
| 1215 | + "Parameters": { |
| 1216 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1217 | + "Name": "ExecutionName" |
| 1218 | + }, |
| 1219 | + "End": True |
| 1220 | + } |
| 1221 | + |
| 1222 | + |
| 1223 | +@patch.object(boto3.session.Session, 'region_name', 'us-east-1') |
| 1224 | +def test_step_functions_start_execution_step_creation_wait_for_task_token(): |
| 1225 | + step = StepFunctionsStartExecutionStep( |
| 1226 | + "SFN Start Execution - Wait for Callback", integration_pattern=IntegrationPattern.WaitForTaskToken, |
| 1227 | + parameters={ |
| 1228 | + "Input": { |
| 1229 | + "token.$": "$$.Task.Token" |
| 1230 | + }, |
| 1231 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1232 | + "Name": "ExecutionName" |
| 1233 | + }) |
| 1234 | + |
| 1235 | + assert step.to_dict() == { |
| 1236 | + "Type": "Task", |
| 1237 | + "Resource": "arn:aws:states:::states:startExecution.waitForTaskToken", |
| 1238 | + "Parameters": { |
| 1239 | + "Input": { |
| 1240 | + "token.$": "$$.Task.Token" |
| 1241 | + }, |
| 1242 | + "StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld", |
| 1243 | + "Name": "ExecutionName" |
| 1244 | + }, |
| 1245 | + "End": True |
| 1246 | + } |
| 1247 | + |
| 1248 | + |
| 1249 | +@pytest.mark.parametrize("integration_pattern", [ |
| 1250 | + None, |
| 1251 | + "ServiceIntegrationTypeStr", |
| 1252 | + 0 |
| 1253 | +]) |
| 1254 | +@patch.object(boto3.session.Session, 'region_name', 'us-east-1') |
| 1255 | +def test_step_functions_start_execution_step_creation_invalid_integration_pattern_raises_type_error(integration_pattern): |
| 1256 | + with pytest.raises(TypeError): |
| 1257 | + StepFunctionsStartExecutionStep("SFN Start Execution - invalid ServiceType", integration_pattern=integration_pattern) |
0 commit comments