Add SWF endpoint: StartWorkflowExecution
This commit is contained in:
parent
fbcdd5f2bd
commit
92cf64c2ad
5 changed files with 177 additions and 6 deletions
|
|
@ -3,6 +3,7 @@ from sure import expect
|
|||
from moto.swf.models import (
|
||||
Domain,
|
||||
GenericType,
|
||||
WorkflowExecution,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -65,3 +66,19 @@ def test_type_full_dict_representation():
|
|||
def test_type_string_representation():
|
||||
_type = FooType("test-foo", "v1.0")
|
||||
str(_type).should.equal("FooType(name: test-foo, version: v1.0, status: REGISTERED)")
|
||||
|
||||
|
||||
# WorkflowExecution
|
||||
def test_workflow_execution_creation():
|
||||
wfe = WorkflowExecution("workflow_type_whatever", child_policy="TERMINATE")
|
||||
wfe.workflow_type.should.equal("workflow_type_whatever")
|
||||
wfe.child_policy.should.equal("TERMINATE")
|
||||
|
||||
def test_workflow_execution_string_representation():
|
||||
wfe = WorkflowExecution("workflow_type_whatever", child_policy="TERMINATE")
|
||||
str(wfe).should.match(r"^WorkflowExecution\(run_id: .*\)")
|
||||
|
||||
def test_workflow_execution_generates_a_random_run_id():
|
||||
wfe1 = WorkflowExecution("workflow_type_whatever")
|
||||
wfe2 = WorkflowExecution("workflow_type_whatever")
|
||||
wfe1.run_id.should_not.equal(wfe2.run_id)
|
||||
|
|
|
|||
59
tests/test_swf/test_workflow_executions.py
Normal file
59
tests/test_swf/test_workflow_executions.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import boto
|
||||
from nose.tools import assert_raises
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.exceptions import (
|
||||
SWFWorkflowExecutionAlreadyStartedFault,
|
||||
SWFTypeDeprecatedFault,
|
||||
)
|
||||
|
||||
|
||||
# Utils
|
||||
@mock_swf
|
||||
def setup_swf_environment():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.1")
|
||||
return conn
|
||||
|
||||
|
||||
# StartWorkflowExecution endpoint
|
||||
@mock_swf
|
||||
def test_start_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
|
||||
wf = conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
wf.should.contain("runId")
|
||||
|
||||
@mock_swf
|
||||
def test_start_already_started_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
|
||||
with assert_raises(SWFWorkflowExecutionAlreadyStartedFault) as err:
|
||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
|
||||
ex = err.exception
|
||||
ex.status.should.equal(400)
|
||||
ex.error_code.should.equal("WorkflowExecutionAlreadyStartedFault")
|
||||
ex.body.should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
||||
})
|
||||
|
||||
@mock_swf
|
||||
def test_start_workflow_execution_on_deprecated_type():
|
||||
conn = setup_swf_environment()
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
with assert_raises(SWFTypeDeprecatedFault) as err:
|
||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
|
||||
ex = err.exception
|
||||
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=test-workflow, version=v1.0]"
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue