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,13 +1,10 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf import swf_backend
|
||||
from moto.swf.exceptions import (
|
||||
SWFValidationException,
|
||||
SWFUnknownResourceFault,
|
||||
)
|
||||
|
||||
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
|
||||
|
|
@ -91,7 +88,7 @@ def test_respond_activity_task_completed_with_wrong_token():
|
|||
conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFValidationException, "Invalid token")
|
||||
).should.throw(SWFResponseError, "Invalid token")
|
||||
|
||||
@mock_swf
|
||||
def test_respond_activity_task_completed_on_closed_workflow_execution():
|
||||
|
|
@ -109,7 +106,7 @@ def test_respond_activity_task_completed_on_closed_workflow_execution():
|
|||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFUnknownResourceFault, "WorkflowExecution=")
|
||||
).should.throw(SWFResponseError, "WorkflowExecution=")
|
||||
|
||||
@mock_swf
|
||||
def test_respond_activity_task_completed_with_task_already_completed():
|
||||
|
|
@ -124,7 +121,7 @@ def test_respond_activity_task_completed_with_task_already_completed():
|
|||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFUnknownResourceFault, "Unknown activity, scheduledEventId = 5")
|
||||
).should.throw(SWFResponseError, "Unknown activity, scheduledEventId = 5")
|
||||
|
||||
|
||||
# RespondActivityTaskFailed endpoint
|
||||
|
|
@ -162,7 +159,7 @@ def test_respond_activity_task_completed_with_wrong_token():
|
|||
conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
conn.respond_activity_task_failed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFValidationException, "Invalid token")
|
||||
).should.throw(SWFResponseError, "Invalid token")
|
||||
|
||||
|
||||
# RecordActivityTaskHeartbeat endpoint
|
||||
|
|
@ -189,7 +186,7 @@ def test_record_activity_task_heartbeat_with_wrong_token():
|
|||
|
||||
conn.record_activity_task_heartbeat.when.called_with(
|
||||
"bad-token", details="some progress details"
|
||||
).should.throw(SWFValidationException)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_record_activity_task_heartbeat_sets_details_in_case_of_timeout():
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFTypeAlreadyExistsFault,
|
||||
SWFTypeDeprecatedFault,
|
||||
SWFSerializationException,
|
||||
)
|
||||
|
||||
|
||||
# RegisterActivityType endpoint
|
||||
|
|
@ -30,7 +25,7 @@ def test_register_already_existing_activity_type():
|
|||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFTypeAlreadyExistsFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_register_with_wrong_parameter_type():
|
||||
|
|
@ -39,7 +34,7 @@ def test_register_with_wrong_parameter_type():
|
|||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", 12
|
||||
).should.throw(SWFSerializationException)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
# ListActivityTypes endpoint
|
||||
@mock_swf
|
||||
|
|
@ -90,7 +85,7 @@ def test_deprecate_already_deprecated_activity_type():
|
|||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFTypeDeprecatedFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_deprecate_non_existent_activity_type():
|
||||
|
|
@ -99,7 +94,7 @@ def test_deprecate_non_existent_activity_type():
|
|||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
# DescribeActivityType endpoint
|
||||
@mock_swf
|
||||
|
|
@ -123,4 +118,4 @@ def test_describe_non_existent_activity_type():
|
|||
|
||||
conn.describe_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf import swf_backend
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFValidationException,
|
||||
SWFDecisionValidationException,
|
||||
)
|
||||
|
||||
from ..utils import setup_workflow
|
||||
|
||||
|
|
@ -114,7 +110,7 @@ def test_respond_decision_task_completed_with_wrong_token():
|
|||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFValidationException)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_respond_decision_task_completed_on_close_workflow_execution():
|
||||
|
|
@ -129,7 +125,7 @@ def test_respond_decision_task_completed_on_close_workflow_execution():
|
|||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_respond_decision_task_completed_with_task_already_completed():
|
||||
|
|
@ -140,7 +136,7 @@ def test_respond_decision_task_completed_with_task_already_completed():
|
|||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_respond_decision_task_completed_with_complete_workflow_execution():
|
||||
|
|
@ -179,7 +175,7 @@ def test_respond_decision_task_completed_with_close_decision_not_last():
|
|||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(SWFValidationException, r"Close must be last decision in list")
|
||||
).should.throw(SWFResponseError, r"Close must be last decision in list")
|
||||
|
||||
@mock_swf
|
||||
def test_respond_decision_task_completed_with_invalid_decision_type():
|
||||
|
|
@ -195,7 +191,7 @@ def test_respond_decision_task_completed_with_invalid_decision_type():
|
|||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFDecisionValidationException,
|
||||
SWFResponseError,
|
||||
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'"
|
||||
)
|
||||
|
||||
|
|
@ -215,7 +211,7 @@ def test_respond_decision_task_completed_with_missing_attributes():
|
|||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFDecisionValidationException,
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' " \
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
|
@ -233,7 +229,7 @@ def test_respond_decision_task_completed_with_missing_attributes_totally():
|
|||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFDecisionValidationException,
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' " \
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFDomainAlreadyExistsFault,
|
||||
SWFDomainDeprecatedFault,
|
||||
SWFSerializationException,
|
||||
)
|
||||
|
||||
|
||||
# RegisterDomain endpoint
|
||||
|
|
@ -30,7 +25,7 @@ def test_register_already_existing_domain():
|
|||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", "60", description="A test domain"
|
||||
).should.throw(SWFDomainAlreadyExistsFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_register_with_wrong_parameter_type():
|
||||
|
|
@ -38,7 +33,7 @@ def test_register_with_wrong_parameter_type():
|
|||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", 60, description="A test domain"
|
||||
).should.throw(SWFSerializationException)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListDomains endpoint
|
||||
|
|
@ -85,7 +80,7 @@ def test_deprecate_already_deprecated_domain():
|
|||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"test-domain"
|
||||
).should.throw(SWFDomainDeprecatedFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_deprecate_non_existent_domain():
|
||||
|
|
@ -93,7 +88,7 @@ def test_deprecate_non_existent_domain():
|
|||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeDomain endpoint
|
||||
|
|
@ -114,4 +109,4 @@ def test_describe_non_existent_domain():
|
|||
|
||||
conn.describe_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises # noqa
|
||||
from nose.tools import assert_raises
|
||||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.exceptions import (
|
||||
SWFWorkflowExecutionAlreadyStartedFault,
|
||||
SWFTypeDeprecatedFault,
|
||||
SWFUnknownResourceFault,
|
||||
)
|
||||
|
||||
|
||||
# Utils
|
||||
|
|
@ -39,7 +39,7 @@ def test_start_already_started_workflow_execution():
|
|||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFWorkflowExecutionAlreadyStartedFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_start_workflow_execution_on_deprecated_type():
|
||||
|
|
@ -48,7 +48,7 @@ def test_start_workflow_execution_on_deprecated_type():
|
|||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFTypeDeprecatedFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowExecution endpoint
|
||||
|
|
@ -68,7 +68,7 @@ def test_describe_non_existent_workflow_execution():
|
|||
|
||||
conn.describe_workflow_execution.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# GetWorkflowExecutionHistory endpoint
|
||||
|
|
@ -99,7 +99,7 @@ def test_get_workflow_execution_history_on_non_existent_workflow_execution():
|
|||
|
||||
conn.get_workflow_execution_history.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# TerminateWorkflowExecution endpoint
|
||||
|
|
@ -138,26 +138,26 @@ def test_terminate_workflow_execution_with_wrong_workflow_or_run_id():
|
|||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", run_id=run_id
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
|
||||
# already closed, without run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "Unknown execution, workflowId = uid-abcd1234"
|
||||
SWFResponseError, "Unknown execution, workflowId = uid-abcd1234"
|
||||
)
|
||||
|
||||
# wrong workflow id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-non-existent"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "Unknown execution, workflowId = uid-non-existent"
|
||||
SWFResponseError, "Unknown execution, workflowId = uid-non-existent"
|
||||
)
|
||||
|
||||
# wrong run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", run_id="foo"
|
||||
).should.throw(
|
||||
SWFUnknownResourceFault, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,7 @@ import boto
|
|||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFTypeAlreadyExistsFault,
|
||||
SWFTypeDeprecatedFault,
|
||||
SWFSerializationException,
|
||||
)
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
|
||||
|
||||
# RegisterWorkflowType endpoint
|
||||
|
|
@ -30,7 +25,7 @@ def test_register_already_existing_workflow_type():
|
|||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFTypeAlreadyExistsFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_register_with_wrong_parameter_type():
|
||||
|
|
@ -39,7 +34,7 @@ def test_register_with_wrong_parameter_type():
|
|||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", 12
|
||||
).should.throw(SWFSerializationException)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListWorkflowTypes endpoint
|
||||
|
|
@ -91,7 +86,7 @@ def test_deprecate_already_deprecated_workflow_type():
|
|||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFTypeDeprecatedFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
@mock_swf
|
||||
def test_deprecate_non_existent_workflow_type():
|
||||
|
|
@ -100,7 +95,7 @@ def test_deprecate_non_existent_workflow_type():
|
|||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowType endpoint
|
||||
|
|
@ -127,4 +122,4 @@ def test_describe_non_existent_workflow_type():
|
|||
|
||||
conn.describe_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFUnknownResourceFault)
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue