Best Python code snippet using localstack_python
test_workflow_executions.py
Source:test_workflow_executions.py  
...108    # One closed workflow execution to make sure it isn't displayed109    run_id = conn.start_workflow_execution(110        'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'111    )['runId']112    conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',113                                      details='some details',114                                      reason='a more complete reason',115                                      run_id=run_id)116    yesterday = datetime.utcnow() - timedelta(days=1)117    oldest_date = unix_time(yesterday)118    response = conn.list_open_workflow_executions('test-domain',119                                                  oldest_date,120                                                  workflow_id='test-workflow')121    execution_infos = response['executionInfos']122    len(execution_infos).should.equal(1)123    open_workflow = execution_infos[0]124    open_workflow['workflowType'].should.equal({'version': 'v1.0',125                                                'name': 'test-workflow'})126    open_workflow.should.contain('startTimestamp')127    open_workflow['execution']['workflowId'].should.equal('uid-abcd1234')128    open_workflow['execution'].should.contain('runId')129    open_workflow['cancelRequested'].should.be(False)130    open_workflow['executionStatus'].should.equal('OPEN')131# ListClosedWorkflowExecutions endpoint132@mock_swf_deprecated133def test_list_closed_workflow_executions():134    conn = setup_swf_environment()135    # Leave one workflow execution open to make sure it isn't displayed136    conn.start_workflow_execution(137        'test-domain', 'uid-abcd1234', 'test-workflow', 'v1.0'138    )139    # One closed workflow execution140    run_id = conn.start_workflow_execution(141        'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'142    )['runId']143    conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',144                                      details='some details',145                                      reason='a more complete reason',146                                      run_id=run_id)147    yesterday = datetime.utcnow() - timedelta(days=1)148    oldest_date = unix_time(yesterday)149    response = conn.list_closed_workflow_executions(150        'test-domain',151        start_oldest_date=oldest_date,152        workflow_id='test-workflow')153    execution_infos = response['executionInfos']154    len(execution_infos).should.equal(1)155    open_workflow = execution_infos[0]156    open_workflow['workflowType'].should.equal({'version': 'v1.0',157                                                'name': 'test-workflow'})158    open_workflow.should.contain('startTimestamp')159    open_workflow['execution']['workflowId'].should.equal('uid-abcd12345')160    open_workflow['execution'].should.contain('runId')161    open_workflow['cancelRequested'].should.be(False)162    open_workflow['executionStatus'].should.equal('CLOSED')163# TerminateWorkflowExecution endpoint164@mock_swf_deprecated165def test_terminate_workflow_execution():166    conn = setup_swf_environment()167    run_id = conn.start_workflow_execution(168        "test-domain", "uid-abcd1234", "test-workflow", "v1.0"169    )["runId"]170    resp = conn.terminate_workflow_execution("test-domain", "uid-abcd1234",171                                             details="some details",172                                             reason="a more complete reason",173                                             run_id=run_id)174    resp.should.be.none175    resp = conn.get_workflow_execution_history(176        "test-domain", run_id, "uid-abcd1234")177    evt = resp["events"][-1]178    evt["eventType"].should.equal("WorkflowExecutionTerminated")179    attrs = evt["workflowExecutionTerminatedEventAttributes"]180    attrs["details"].should.equal("some details")181    attrs["reason"].should.equal("a more complete reason")182    attrs["cause"].should.equal("OPERATOR_INITIATED")183@mock_swf_deprecated184def test_terminate_workflow_execution_with_wrong_workflow_or_run_id():185    conn = setup_swf_environment()186    run_id = conn.start_workflow_execution(187        "test-domain", "uid-abcd1234", "test-workflow", "v1.0"188    )["runId"]189    # terminate workflow execution190    conn.terminate_workflow_execution("test-domain", "uid-abcd1234")191    # already closed, with run_id192    conn.terminate_workflow_execution.when.called_with(193        "test-domain", "uid-abcd1234", run_id=run_id194    ).should.throw(195        SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="196    )197    # already closed, without run_id198    conn.terminate_workflow_execution.when.called_with(199        "test-domain", "uid-abcd1234"200    ).should.throw(201        SWFResponseError, "Unknown execution, workflowId = uid-abcd1234"202    )203    # wrong workflow id204    conn.terminate_workflow_execution.when.called_with(...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
