def test_workflow_execution_creation_child_policy_logic(): domain = get_basic_domain() WorkflowExecution( domain, WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ), "ab1234", ).child_policy.should.equal("ABANDON") WorkflowExecution( domain, WorkflowType( "test-workflow", "v1.0", task_list="queue", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ), "ab1234", child_policy="REQUEST_CANCEL", ).child_policy.should.equal("REQUEST_CANCEL") WorkflowExecution.when.called_with( domain, WorkflowType("test-workflow", "v1.0"), "ab1234").should.throw(SWFDefaultUndefinedFault)
def test_workflow_execution_full_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ) wfe = WorkflowExecution(domain, wf_type, "ab1234") fd = wfe.to_full_dict() fd["executionInfo"].should.equal(wfe.to_medium_dict()) fd["openCounts"]["openTimers"].should.equal(0) fd["openCounts"]["openDecisionTasks"].should.equal(0) fd["openCounts"]["openActivityTasks"].should.equal(0) fd["executionConfiguration"].should.equal( { "childPolicy": "ABANDON", "executionStartToCloseTimeout": "300", "taskList": {"name": "queue"}, "taskStartToCloseTimeout": "300", } )
def test_workflow_execution_full_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ) wfe = WorkflowExecution(domain, wf_type, "ab1234") fd = wfe.to_full_dict() fd["executionInfo"].should.equal(wfe.to_medium_dict()) fd["openCounts"]["openTimers"].should.equal(0) fd["openCounts"]["openDecisionTasks"].should.equal(0) fd["openCounts"]["openActivityTasks"].should.equal(0) fd["executionConfiguration"].should.equal({ "childPolicy": "ABANDON", "executionStartToCloseTimeout": "300", "taskList": { "name": "queue" }, "taskStartToCloseTimeout": "300", })
def test_workflow_execution_short_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ) wfe = WorkflowExecution(domain, wf_type, "ab1234") sd = wfe.to_short_dict() sd["workflowId"].should.equal("ab1234") sd.should.contain("runId")
def test_workflow_execution_creation(): domain = get_basic_domain() wft = get_basic_workflow_type() wfe = WorkflowExecution(domain, wft, "ab1234", child_policy="TERMINATE") wfe.domain.should.equal(domain) wfe.workflow_type.should.equal(wft) wfe.child_policy.should.equal("TERMINATE")
def test_workflow_execution_list_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( 'test-workflow', 'v1.0', task_list='queue', default_child_policy='ABANDON', default_execution_start_to_close_timeout='300', default_task_start_to_close_timeout='300', ) wfe = WorkflowExecution(domain, wf_type, 'ab1234') ld = wfe.to_list_dict() ld['workflowType']['version'].should.equal('v1.0') ld['workflowType']['name'].should.equal('test-workflow') ld['executionStatus'].should.equal('OPEN') ld['execution']['workflowId'].should.equal('ab1234') ld['execution'].should.contain('runId') ld['cancelRequested'].should.be.false ld.should.contain('startTimestamp')
def test_workflow_execution_list_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ) wfe = WorkflowExecution(domain, wf_type, "ab1234") ld = wfe.to_list_dict() ld["workflowType"]["version"].should.equal("v1.0") ld["workflowType"]["name"].should.equal("test-workflow") ld["executionStatus"].should.equal("OPEN") ld["execution"]["workflowId"].should.equal("ab1234") ld["execution"].should.contain("runId") ld["cancelRequested"].should.be.false ld.should.contain("startTimestamp")
def test_workflow_execution_medium_dict_representation(): domain = get_basic_domain() wf_type = WorkflowType( "test-workflow", "v1.0", task_list="queue", default_child_policy="ABANDON", default_execution_start_to_close_timeout="300", default_task_start_to_close_timeout="300", ) wfe = WorkflowExecution(domain, wf_type, "ab1234") md = wfe.to_medium_dict() md["execution"].should.equal(wfe.to_short_dict()) md["workflowType"].should.equal(wf_type.to_short_dict()) md["startTimestamp"].should.be.a('float') md["executionStatus"].should.equal("OPEN") md["cancelRequested"].should.be.falsy md.should_not.contain("tagList") wfe.tag_list = ["foo", "bar", "baz"] md = wfe.to_medium_dict() md["tagList"].should.equal(["foo", "bar", "baz"])
def make_workflow_execution(**kwargs): domain = get_basic_domain() domain.add_type(ActivityType("test-activity", "v1.1")) wft = get_basic_workflow_type() return WorkflowExecution(domain, wft, "ab1234", **kwargs)
def test_workflow_execution_generates_a_random_run_id(): domain = get_basic_domain() wft = get_basic_workflow_type() wfe1 = WorkflowExecution(domain, wft, "ab1234", child_policy="TERMINATE") wfe2 = WorkflowExecution(domain, wft, "ab1235", child_policy="TERMINATE") wfe1.run_id.should_not.equal(wfe2.run_id)