Add SWF endpoint TerminateWorkflowExecution
This commit is contained in:
parent
98948a01c8
commit
96d6bb056b
10 changed files with 212 additions and 16 deletions
|
|
@ -1,8 +1,17 @@
|
|||
from collections import namedtuple
|
||||
from sure import expect
|
||||
|
||||
from moto.swf.exceptions import SWFUnknownResourceFault
|
||||
from moto.swf.models import Domain
|
||||
|
||||
|
||||
# Fake WorkflowExecution for tests purposes
|
||||
WorkflowExecution = namedtuple(
|
||||
"WorkflowExecution",
|
||||
["workflow_id", "run_id", "execution_status"]
|
||||
)
|
||||
|
||||
|
||||
def test_domain_short_dict_representation():
|
||||
domain = Domain("foo", "52")
|
||||
domain.to_short_dict().should.equal({"name":"foo", "status":"REGISTERED"})
|
||||
|
|
@ -46,3 +55,45 @@ def test_domain_decision_tasks():
|
|||
domain.add_to_decision_task_list("foo", "bar")
|
||||
domain.add_to_decision_task_list("other", "baz")
|
||||
domain.decision_tasks.should.equal(["bar", "baz"])
|
||||
|
||||
def test_domain_get_workflow_execution():
|
||||
domain = Domain("my-domain", "60")
|
||||
|
||||
wfe1 = WorkflowExecution(workflow_id="wf-id-1", run_id="run-id-1", execution_status="OPEN")
|
||||
wfe2 = WorkflowExecution(workflow_id="wf-id-1", run_id="run-id-2", execution_status="CLOSED")
|
||||
wfe3 = WorkflowExecution(workflow_id="wf-id-2", run_id="run-id-3", execution_status="OPEN")
|
||||
wfe4 = WorkflowExecution(workflow_id="wf-id-3", run_id="run-id-4", execution_status="CLOSED")
|
||||
domain.workflow_executions = [wfe1, wfe2, wfe3, wfe4]
|
||||
|
||||
# get workflow execution through workflow_id and run_id
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-1").should.equal(wfe1)
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-2").should.equal(wfe2)
|
||||
domain.get_workflow_execution("wf-id-3", run_id="run-id-4").should.equal(wfe4)
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-1", run_id="non-existent"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault,
|
||||
"Unknown execution: WorkflowExecution=[workflowId=wf-id-1, runId=non-existent]"
|
||||
)
|
||||
|
||||
# get OPEN workflow execution by default if no run_id
|
||||
domain.get_workflow_execution("wf-id-1").should.equal(wfe1)
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-3"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "Unknown execution, workflowId = wf-id-3"
|
||||
)
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-non-existent"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "Unknown execution, workflowId = wf-id-non-existent"
|
||||
)
|
||||
|
||||
# raise_if_closed attribute
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-1", raise_if_closed=True).should.equal(wfe1)
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-3", run_id="run-id-4", raise_if_closed=True
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault,
|
||||
"Unknown execution: WorkflowExecution=[workflowId=wf-id-3, runId=run-id-4]"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue