def test_start_state_machines(self, mock_time, mock_send_next_event_for_dispatch): mock_time.time.return_value = 12345. start_state_machines('name', [{'aaa': 'bbb'}, {'ccc': 'ddd'}], correlation_ids=['a', 'b']) mock_send_next_event_for_dispatch.assert_called_with( None, ['{"system_context": {"additional_delay_seconds": 0, "correlation_id": "a", "current_event": ' '"pseudo_init", "current_state": "pseudo_init", "machine_name": "name", "retries": 0, ' '"started_at": 12345, "steps": 0}, "user_context": {"aaa": "bbb"}, "version": "0.1"}', '{"system_context": {"additional_delay_seconds": 0, "correlation_id": "b", "current_event": ' '"pseudo_init", "current_state": "pseudo_init", "machine_name": "name", "retries": 0, ' '"started_at": 12345, "steps": 0}, "user_context": {"ccc": "ddd"}, "version": "0.1"}'], ['a', 'b'] )
logging.basicConfig( format='[%(levelname)s] %(asctime)-15s %(message)s', level=int(args.log_level) if args.log_level.isdigit() else args.log_level, datefmt='%Y-%m-%d %H:%M:%S') logging.getLogger('boto3').setLevel(args.boto_log_level) logging.getLogger('botocore').setLevel(args.boto_log_level) validate_config() if args.num_machines > 1: # start things off context = json.loads(args.initial_context or "{}") current_state = current_event = STATE.PSEUDO_INIT start_state_machines(args.machine_name, [context] * args.num_machines, current_state=current_state, current_event=current_event) exit(0) # checkpoint specified, so start with a context saved to the kinesis stream if args.checkpoint_shard_id and args.checkpoint_sequence_number: # setup connections to AWS kinesis_stream_arn = getattr(settings, args.kinesis_stream_arn) logging.info('Kinesis stream ARN: %s', kinesis_stream_arn) logging.info('Kinesis endpoint: %s', settings.ENDPOINTS.get(AWS.KINESIS)) if get_arn_from_arn_string(kinesis_stream_arn).service != AWS.KINESIS: logging.fatal("%s is not a Kinesis ARN", kinesis_stream_arn) sys.exit(1) kinesis_conn = get_connection(kinesis_stream_arn) kinesis_stream = get_arn_from_arn_string(