Cleanup SWF to use HTTP exceptions so that the standalone server will work. Closes #495.
This commit is contained in:
parent
075d008509
commit
a53a97d136
12 changed files with 136 additions and 142 deletions
|
|
@ -1,5 +1,8 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
import sure
|
||||
|
||||
from moto.swf.exceptions import (
|
||||
SWFClientError,
|
||||
SWFUnknownResourceFault,
|
||||
|
|
@ -18,11 +21,10 @@ from moto.swf.models import (
|
|||
)
|
||||
|
||||
def test_swf_client_error():
|
||||
ex = SWFClientError("error message", "ASpecificType")
|
||||
ex = SWFClientError("ASpecificType", "error message")
|
||||
|
||||
ex.status.should.equal(400)
|
||||
ex.error_code.should.equal("ASpecificType")
|
||||
ex.body.should.equal({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "ASpecificType",
|
||||
"message": "error message"
|
||||
})
|
||||
|
|
@ -30,9 +32,8 @@ def test_swf_client_error():
|
|||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
||||
"message": "Unknown type: detail"
|
||||
})
|
||||
|
|
@ -40,9 +41,8 @@ def test_swf_unknown_resource_fault():
|
|||
def test_swf_unknown_resource_fault_with_only_one_parameter():
|
||||
ex = SWFUnknownResourceFault("foo bar baz")
|
||||
|
||||
ex.status.should.equal(400)
|
||||
ex.error_code.should.equal("UnknownResourceFault")
|
||||
ex.body.should.equal({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#UnknownResourceFault",
|
||||
"message": "Unknown foo bar baz"
|
||||
})
|
||||
|
|
@ -50,9 +50,8 @@ def test_swf_unknown_resource_fault_with_only_one_parameter():
|
|||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#DomainAlreadyExistsFault",
|
||||
"message": "domain-name"
|
||||
})
|
||||
|
|
@ -60,9 +59,8 @@ def test_swf_domain_already_exists_fault():
|
|||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#DomainDeprecatedFault",
|
||||
"message": "domain-name"
|
||||
})
|
||||
|
|
@ -70,18 +68,18 @@ def test_swf_domain_deprecated_fault():
|
|||
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")
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#SerializationException",
|
||||
"message": "class java.lang.Foo can not be converted to an String (not a real SWF exception ; happened on: value)"
|
||||
})
|
||||
|
||||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#TypeAlreadyExistsFault",
|
||||
"message": "WorkflowType=[name=wf-name, version=wf-version]"
|
||||
})
|
||||
|
|
@ -90,9 +88,8 @@ 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({
|
||||
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]"
|
||||
})
|
||||
|
|
@ -100,18 +97,17 @@ def test_swf_type_deprecated_fault():
|
|||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#WorkflowExecutionAlreadyStartedFault",
|
||||
'message': 'Already Started',
|
||||
})
|
||||
|
||||
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({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazonaws.swf.base.model#DefaultUndefinedFault",
|
||||
"message": "executionStartToCloseTimeout",
|
||||
})
|
||||
|
|
@ -119,9 +115,8 @@ def test_swf_default_undefined_fault():
|
|||
def test_swf_validation_exception():
|
||||
ex = SWFValidationException("Invalid token")
|
||||
|
||||
ex.status.should.equal(400)
|
||||
ex.error_code.should.equal("ValidationException")
|
||||
ex.body.should.equal({
|
||||
ex.code.should.equal(400)
|
||||
json.loads(ex.get_body()).should.equal({
|
||||
"__type": "com.amazon.coral.validate#ValidationException",
|
||||
"message": "Invalid token",
|
||||
})
|
||||
|
|
@ -136,12 +131,11 @@ def test_swf_decision_validation_error():
|
|||
"possible_values": "Foo, Bar, Baz"},
|
||||
])
|
||||
|
||||
ex.status.should.equal(400)
|
||||
ex.error_code.should.equal("ValidationException")
|
||||
ex.body["__type"].should.equal("com.amazon.coral.validate#ValidationException")
|
||||
ex.code.should.equal(400)
|
||||
ex.error_type.should.equal("com.amazon.coral.validate#ValidationException")
|
||||
|
||||
msg = ex.body["message"]
|
||||
msg.should.match(r"^2 validation errors detected:")
|
||||
msg = ex.get_body()
|
||||
msg.should.match(r"2 validation errors detected:")
|
||||
msg.should.match(
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.startToFireTimeout' "\
|
||||
r"failed to satisfy constraint: Member must not be null;"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue