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_closed_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") wfe.execution_status = "CLOSED" wfe.close_status = "CANCELED" wfe.close_timestamp = 1420066801.123 fd = wfe.to_full_dict() medium_dict = wfe.to_medium_dict() medium_dict["closeStatus"] = "CANCELED" medium_dict["closeTimestamp"] = 1420066801.123 fd["executionInfo"].should.equal(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_swf_type_deprecated_fault(): wft = WorkflowType("wf-name", "wf-version") ex = SWFTypeDeprecatedFault(wft) ex.code.should.equal(400) json.loads(ex.get_body()).should.equal({ "__type": "com.amazonaws.swf.base.model#TypeDeprecatedFault", "message": "WorkflowType=[name=wf-name, version=wf-version]", })
def test_swf_type_deprecated_fault(): wft = WorkflowType("wf-name", "wf-version") ex = SWFTypeDeprecatedFault(wft) ex.status.should.equal(400) ex.error_code.should.equal("TypeDeprecatedFault") ex.body.should.equal({ "__type": "com.amazonaws.swf.base.model#TypeDeprecatedFault", "message": "WorkflowType=[name=wf-name, version=wf-version]" })
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 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 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_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 get_basic_workflow_type(): args, kwargs = _generic_workflow_type_attributes() return WorkflowType(*args, **kwargs)