Refactor SWF exceptions testing so responses tests get simpler
This commit is contained in:
parent
464aef293c
commit
8d435d8afe
@ -1,5 +1,4 @@
|
|||||||
import boto
|
import boto
|
||||||
from nose.tools import assert_raises
|
|
||||||
from sure import expect
|
from sure import expect
|
||||||
|
|
||||||
from moto import mock_swf
|
from moto import mock_swf
|
||||||
@ -29,30 +28,18 @@ def test_register_already_existing_activity_type():
|
|||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFTypeAlreadyExistsFault) as err:
|
conn.register_activity_type.when.called_with(
|
||||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
"test-domain", "test-activity", "v1.0"
|
||||||
|
).should.throw(SWFTypeAlreadyExistsFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("TypeAlreadyExistsFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
|
||||||
"message": "ActivityType=[name=test-activity, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_register_with_wrong_parameter_type():
|
def test_register_with_wrong_parameter_type():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFSerializationException) as err:
|
conn.register_activity_type.when.called_with(
|
||||||
conn.register_activity_type("test-domain", "test-activity", 12)
|
"test-domain", "test-activity", 12
|
||||||
|
).should.throw(SWFSerializationException)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("SerializationException")
|
|
||||||
ex.body["__type"].should.equal("com.amazonaws.swf.base.model#SerializationException")
|
|
||||||
|
|
||||||
|
|
||||||
# ListActivityTypes endpoint
|
# ListActivityTypes endpoint
|
||||||
@mock_swf
|
@mock_swf
|
||||||
@ -101,32 +88,18 @@ def test_deprecate_already_deprecated_activity_type():
|
|||||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFTypeDeprecatedFault) as err:
|
conn.deprecate_activity_type.when.called_with(
|
||||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
"test-domain", "test-activity", "v1.0"
|
||||||
|
).should.throw(SWFTypeDeprecatedFault)
|
||||||
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": "ActivityType=[name=test-activity, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_deprecate_non_existent_activity_type():
|
def test_deprecate_non_existent_activity_type():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.deprecate_activity_type.when.called_with(
|
||||||
conn.deprecate_activity_type("test-domain", "non-existent", "v1.0")
|
"test-domain", "non-existent", "v1.0"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown type: ActivityType=[name=non-existent, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
|
||||||
# DescribeActivityType endpoint
|
# DescribeActivityType endpoint
|
||||||
@mock_swf
|
@mock_swf
|
||||||
@ -148,13 +121,6 @@ def test_describe_non_existent_activity_type():
|
|||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.describe_activity_type.when.called_with(
|
||||||
conn.describe_activity_type("test-domain", "non-existent", "v1.0")
|
"test-domain", "non-existent", "v1.0"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown type: ActivityType=[name=non-existent, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import boto
|
import boto
|
||||||
from nose.tools import assert_raises
|
|
||||||
from sure import expect
|
from sure import expect
|
||||||
|
|
||||||
from moto import mock_swf
|
from moto import mock_swf
|
||||||
@ -29,28 +28,17 @@ def test_register_already_existing_domain():
|
|||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60", description="A test domain")
|
conn.register_domain("test-domain", "60", description="A test domain")
|
||||||
|
|
||||||
with assert_raises(SWFDomainAlreadyExistsFault) as err:
|
conn.register_domain.when.called_with(
|
||||||
conn.register_domain("test-domain", "60", description="A test domain")
|
"test-domain", "60", description="A test domain"
|
||||||
|
).should.throw(SWFDomainAlreadyExistsFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("DomainAlreadyExistsFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#DomainAlreadyExistsFault",
|
|
||||||
"message": "test-domain"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_register_with_wrong_parameter_type():
|
def test_register_with_wrong_parameter_type():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
|
|
||||||
with assert_raises(SWFSerializationException) as err:
|
conn.register_domain.when.called_with(
|
||||||
conn.register_domain("test-domain", 60, description="A test domain")
|
"test-domain", 60, description="A test domain"
|
||||||
|
).should.throw(SWFSerializationException)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("SerializationException")
|
|
||||||
ex.body["__type"].should.equal("com.amazonaws.swf.base.model#SerializationException")
|
|
||||||
|
|
||||||
|
|
||||||
# ListDomains endpoint
|
# ListDomains endpoint
|
||||||
@ -95,31 +83,18 @@ def test_deprecate_already_deprecated_domain():
|
|||||||
conn.register_domain("test-domain", "60", description="A test domain")
|
conn.register_domain("test-domain", "60", description="A test domain")
|
||||||
conn.deprecate_domain("test-domain")
|
conn.deprecate_domain("test-domain")
|
||||||
|
|
||||||
with assert_raises(SWFDomainDeprecatedFault) as err:
|
conn.deprecate_domain.when.called_with(
|
||||||
conn.deprecate_domain("test-domain")
|
"test-domain"
|
||||||
|
).should.throw(SWFDomainDeprecatedFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("DomainDeprecatedFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#DomainDeprecatedFault",
|
|
||||||
"message": "test-domain"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_deprecate_non_existent_domain():
|
def test_deprecate_non_existent_domain():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.deprecate_domain.when.called_with(
|
||||||
conn.deprecate_domain("non-existent")
|
"non-existent"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
|
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown domain: non-existent"
|
|
||||||
})
|
|
||||||
|
|
||||||
# DescribeDomain endpoint
|
# DescribeDomain endpoint
|
||||||
@mock_swf
|
@mock_swf
|
||||||
@ -137,13 +112,6 @@ def test_describe_domain():
|
|||||||
def test_describe_non_existent_domain():
|
def test_describe_non_existent_domain():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.describe_domain.when.called_with(
|
||||||
conn.describe_domain("non-existent")
|
"non-existent"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown domain: non-existent"
|
|
||||||
})
|
|
||||||
|
105
tests/test_swf/test_exceptions.py
Normal file
105
tests/test_swf/test_exceptions.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from moto.swf.exceptions import (
|
||||||
|
SWFClientError,
|
||||||
|
SWFUnknownResourceFault,
|
||||||
|
SWFDomainAlreadyExistsFault,
|
||||||
|
SWFDomainDeprecatedFault,
|
||||||
|
SWFSerializationException,
|
||||||
|
SWFTypeAlreadyExistsFault,
|
||||||
|
SWFTypeDeprecatedFault,
|
||||||
|
SWFWorkflowExecutionAlreadyStartedFault,
|
||||||
|
SWFDefaultUndefinedFault,
|
||||||
|
)
|
||||||
|
from moto.swf.models import (
|
||||||
|
WorkflowType,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_swf_client_error():
|
||||||
|
ex = SWFClientError("error message", "ASpecificType")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("ASpecificType")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "ASpecificType",
|
||||||
|
"message": "error message"
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_swf_unknown_resource_fault():
|
||||||
|
ex = SWFUnknownResourceFault("type", "detail")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("UnknownResourceFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
||||||
|
"message": "Unknown type: detail"
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_swf_domain_already_exists_fault():
|
||||||
|
ex = SWFDomainAlreadyExistsFault("domain-name")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("DomainAlreadyExistsFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#DomainAlreadyExistsFault",
|
||||||
|
"message": "domain-name"
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_swf_domain_deprecated_fault():
|
||||||
|
ex = SWFDomainDeprecatedFault("domain-name")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("DomainDeprecatedFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#DomainDeprecatedFault",
|
||||||
|
"message": "domain-name"
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_swf_serialization_exception():
|
||||||
|
ex = SWFSerializationException("value")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("SerializationException")
|
||||||
|
ex.body["__type"].should.equal("com.amazonaws.swf.base.model#SerializationException")
|
||||||
|
ex.body["Message"].should.match(r"class java.lang.Foo can not be converted to an String")
|
||||||
|
|
||||||
|
def test_swf_type_already_exists_fault():
|
||||||
|
wft = WorkflowType("wf-name", "wf-version")
|
||||||
|
ex = SWFTypeAlreadyExistsFault(wft)
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("TypeAlreadyExistsFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
||||||
|
"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_swf_workflow_execution_already_started_fault():
|
||||||
|
ex = SWFWorkflowExecutionAlreadyStartedFault()
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("WorkflowExecutionAlreadyStartedFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_swf_default_undefined_fault():
|
||||||
|
ex = SWFDefaultUndefinedFault("execution_start_to_close_timeout")
|
||||||
|
|
||||||
|
ex.status.should.equal(400)
|
||||||
|
ex.error_code.should.equal("DefaultUndefinedFault")
|
||||||
|
ex.body.should.equal({
|
||||||
|
"__type": "com.amazonaws.swf.base.model#DefaultUndefinedFault",
|
||||||
|
"message": "executionStartToCloseTimeout",
|
||||||
|
})
|
@ -1,5 +1,4 @@
|
|||||||
from sure import expect
|
from sure import expect
|
||||||
from nose.tools import assert_raises
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from moto.swf.models import (
|
from moto.swf.models import (
|
||||||
@ -112,16 +111,9 @@ def test_workflow_execution_creation_child_policy_logic():
|
|||||||
child_policy="REQUEST_CANCEL"
|
child_policy="REQUEST_CANCEL"
|
||||||
).child_policy.should.equal("REQUEST_CANCEL")
|
).child_policy.should.equal("REQUEST_CANCEL")
|
||||||
|
|
||||||
with assert_raises(SWFDefaultUndefinedFault) as err:
|
WorkflowExecution.when.called_with(
|
||||||
WorkflowExecution(WorkflowType("test-workflow", "v1.0"), "ab1234")
|
WorkflowType("test-workflow", "v1.0"), "ab1234"
|
||||||
|
).should.throw(SWFDefaultUndefinedFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("DefaultUndefinedFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#DefaultUndefinedFault",
|
|
||||||
"message": "executionStartToCloseTimeout"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def test_workflow_execution_string_representation():
|
def test_workflow_execution_string_representation():
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import boto
|
import boto
|
||||||
from nose.tools import assert_raises
|
|
||||||
from sure import expect
|
from sure import expect
|
||||||
|
|
||||||
from moto import mock_swf
|
from moto import mock_swf
|
||||||
@ -38,31 +37,18 @@ def test_start_already_started_workflow_execution():
|
|||||||
conn = setup_swf_environment()
|
conn = setup_swf_environment()
|
||||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFWorkflowExecutionAlreadyStartedFault) as err:
|
conn.start_workflow_execution.when.called_with(
|
||||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||||
|
).should.throw(SWFWorkflowExecutionAlreadyStartedFault)
|
||||||
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
|
@mock_swf
|
||||||
def test_start_workflow_execution_on_deprecated_type():
|
def test_start_workflow_execution_on_deprecated_type():
|
||||||
conn = setup_swf_environment()
|
conn = setup_swf_environment()
|
||||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFTypeDeprecatedFault) as err:
|
conn.start_workflow_execution.when.called_with(
|
||||||
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||||
|
).should.throw(SWFTypeDeprecatedFault)
|
||||||
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]"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
# DescribeWorkflowExecution endpoint
|
# DescribeWorkflowExecution endpoint
|
||||||
@ -80,16 +66,9 @@ def test_describe_workflow_execution():
|
|||||||
def test_describe_non_existent_workflow_execution():
|
def test_describe_non_existent_workflow_execution():
|
||||||
conn = setup_swf_environment()
|
conn = setup_swf_environment()
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.describe_workflow_execution.when.called_with(
|
||||||
conn.describe_workflow_execution("test-domain", "wrong-run-id", "wrong-workflow-id")
|
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown execution: WorkflowExecution=[workflowId=wrong-workflow-id, runId=wrong-run-id]"
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
# GetWorkflowExecutionHistory endpoint
|
# GetWorkflowExecutionHistory endpoint
|
||||||
@ -109,7 +88,6 @@ def test_get_workflow_execution_history():
|
|||||||
def test_get_workflow_execution_history_on_non_existent_workflow_execution():
|
def test_get_workflow_execution_history_on_non_existent_workflow_execution():
|
||||||
conn = setup_swf_environment()
|
conn = setup_swf_environment()
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.get_workflow_execution_history.when.called_with(
|
||||||
conn.get_workflow_execution_history("test-domain", "wrong-run-id", "wrong-workflow-id")
|
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
# (the rest is already tested above)
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import boto
|
import boto
|
||||||
from nose.tools import assert_raises
|
|
||||||
from sure import expect
|
from sure import expect
|
||||||
|
|
||||||
from moto import mock_swf
|
from moto import mock_swf
|
||||||
@ -29,29 +28,18 @@ def test_register_already_existing_workflow_type():
|
|||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFTypeAlreadyExistsFault) as err:
|
conn.register_workflow_type.when.called_with(
|
||||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
"test-domain", "test-workflow", "v1.0"
|
||||||
|
).should.throw(SWFTypeAlreadyExistsFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("TypeAlreadyExistsFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
|
||||||
"message": "WorkflowType=[name=test-workflow, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_register_with_wrong_parameter_type():
|
def test_register_with_wrong_parameter_type():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFSerializationException) as err:
|
conn.register_workflow_type.when.called_with(
|
||||||
conn.register_workflow_type("test-domain", "test-workflow", 12)
|
"test-domain", "test-workflow", 12
|
||||||
|
).should.throw(SWFSerializationException)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("SerializationException")
|
|
||||||
ex.body["__type"].should.equal("com.amazonaws.swf.base.model#SerializationException")
|
|
||||||
|
|
||||||
|
|
||||||
# ListWorkflowTypes endpoint
|
# ListWorkflowTypes endpoint
|
||||||
@ -101,32 +89,19 @@ def test_deprecate_already_deprecated_workflow_type():
|
|||||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||||
|
|
||||||
with assert_raises(SWFTypeDeprecatedFault) as err:
|
conn.deprecate_workflow_type.when.called_with(
|
||||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
"test-domain", "test-workflow", "v1.0"
|
||||||
|
).should.throw(SWFTypeDeprecatedFault)
|
||||||
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]"
|
|
||||||
})
|
|
||||||
|
|
||||||
@mock_swf
|
@mock_swf
|
||||||
def test_deprecate_non_existent_workflow_type():
|
def test_deprecate_non_existent_workflow_type():
|
||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.deprecate_workflow_type.when.called_with(
|
||||||
conn.deprecate_workflow_type("test-domain", "non-existent", "v1.0")
|
"test-domain", "non-existent", "v1.0"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
|
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown type: WorkflowType=[name=non-existent, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
|
||||||
# DescribeWorkflowType endpoint
|
# DescribeWorkflowType endpoint
|
||||||
@mock_swf
|
@mock_swf
|
||||||
@ -150,13 +125,6 @@ def test_describe_non_existent_workflow_type():
|
|||||||
conn = boto.connect_swf("the_key", "the_secret")
|
conn = boto.connect_swf("the_key", "the_secret")
|
||||||
conn.register_domain("test-domain", "60")
|
conn.register_domain("test-domain", "60")
|
||||||
|
|
||||||
with assert_raises(SWFUnknownResourceFault) as err:
|
conn.describe_workflow_type.when.called_with(
|
||||||
conn.describe_workflow_type("test-domain", "non-existent", "v1.0")
|
"test-domain", "non-existent", "v1.0"
|
||||||
|
).should.throw(SWFUnknownResourceFault)
|
||||||
ex = err.exception
|
|
||||||
ex.status.should.equal(400)
|
|
||||||
ex.error_code.should.equal("UnknownResourceFault")
|
|
||||||
ex.body.should.equal({
|
|
||||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
|
||||||
"message": "Unknown type: WorkflowType=[name=non-existent, version=v1.0]"
|
|
||||||
})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user