merge
This commit is contained in:
parent
181b5539f6
commit
e51d1bfade
172 changed files with 49629 additions and 49629 deletions
|
|
@ -1,228 +1,228 @@
|
|||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.swf import swf_backend
|
||||
|
||||
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
|
||||
|
||||
# PollForActivityTask endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_when_one():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
resp = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list", identity="surprise")
|
||||
resp["activityId"].should.equal("my-activity-001")
|
||||
resp["taskToken"].should_not.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-1]["eventType"].should.equal("ActivityTaskStarted")
|
||||
resp["events"][-1]["activityTaskStartedEventAttributes"].should.equal(
|
||||
{"identity": "surprise", "scheduledEventId": 5}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_when_none():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
resp.should.equal({"startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_on_non_existent_queue():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_activity_task("test-domain", "non-existent-queue")
|
||||
resp.should.equal({"startedEventId": 0})
|
||||
|
||||
|
||||
# CountPendingActivityTasks endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_activity_tasks():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
|
||||
resp = conn.count_pending_activity_tasks(
|
||||
"test-domain", "activity-task-list")
|
||||
resp.should.equal({"count": 1, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_on_non_existent_task_list():
|
||||
conn = setup_workflow()
|
||||
resp = conn.count_pending_activity_tasks("test-domain", "non-existent")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
# RespondActivityTaskCompleted endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.respond_activity_task_completed(
|
||||
activity_token, result="result of the task")
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskCompleted")
|
||||
resp["events"][-2]["activityTaskCompletedEventAttributes"].should.equal(
|
||||
{"result": "result of the task", "scheduledEventId": 5, "startedEventId": 6}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_on_closed_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
# bad: we're closing workflow execution manually, but endpoints are not
|
||||
# coded for now..
|
||||
wfe = swf_backend.domains[0].workflow_executions[-1]
|
||||
wfe.execution_status = "CLOSED"
|
||||
# /bad
|
||||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFResponseError, "WorkflowExecution=")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_with_task_already_completed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
conn.respond_activity_task_completed(activity_token)
|
||||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFResponseError, "Unknown activity, scheduledEventId = 5")
|
||||
|
||||
|
||||
# RespondActivityTaskFailed endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_failed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.respond_activity_task_failed(activity_token,
|
||||
reason="short reason",
|
||||
details="long details")
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskFailed")
|
||||
resp["events"][-2]["activityTaskFailedEventAttributes"].should.equal(
|
||||
{"reason": "short reason", "details": "long details",
|
||||
"scheduledEventId": 5, "startedEventId": 6}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_with_wrong_token():
|
||||
# NB: we just test ONE failure case for RespondActivityTaskFailed
|
||||
# because the safeguards are shared with RespondActivityTaskCompleted, so
|
||||
# no need to retest everything end-to-end.
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
conn.respond_activity_task_failed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFResponseError, "Invalid token")
|
||||
|
||||
|
||||
# RecordActivityTaskHeartbeat endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.record_activity_task_heartbeat(activity_token)
|
||||
resp.should.equal({"cancelRequested": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat_with_wrong_token():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
conn.record_activity_task_heartbeat.when.called_with(
|
||||
"bad-token", details="some progress details"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat_sets_details_in_case_of_timeout():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
conn.record_activity_task_heartbeat(
|
||||
activity_token, details="some progress details")
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Activity Task Heartbeat timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskTimedOut")
|
||||
attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"]
|
||||
attrs["details"].should.equal("some progress details")
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.swf import swf_backend
|
||||
|
||||
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
|
||||
|
||||
# PollForActivityTask endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_when_one():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
resp = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list", identity="surprise")
|
||||
resp["activityId"].should.equal("my-activity-001")
|
||||
resp["taskToken"].should_not.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-1]["eventType"].should.equal("ActivityTaskStarted")
|
||||
resp["events"][-1]["activityTaskStartedEventAttributes"].should.equal(
|
||||
{"identity": "surprise", "scheduledEventId": 5}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_when_none():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
resp.should.equal({"startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_activity_task_on_non_existent_queue():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_activity_task("test-domain", "non-existent-queue")
|
||||
resp.should.equal({"startedEventId": 0})
|
||||
|
||||
|
||||
# CountPendingActivityTasks endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_activity_tasks():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
|
||||
resp = conn.count_pending_activity_tasks(
|
||||
"test-domain", "activity-task-list")
|
||||
resp.should.equal({"count": 1, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_on_non_existent_task_list():
|
||||
conn = setup_workflow()
|
||||
resp = conn.count_pending_activity_tasks("test-domain", "non-existent")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
# RespondActivityTaskCompleted endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.respond_activity_task_completed(
|
||||
activity_token, result="result of the task")
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskCompleted")
|
||||
resp["events"][-2]["activityTaskCompletedEventAttributes"].should.equal(
|
||||
{"result": "result of the task", "scheduledEventId": 5, "startedEventId": 6}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_on_closed_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
# bad: we're closing workflow execution manually, but endpoints are not
|
||||
# coded for now..
|
||||
wfe = swf_backend.domains[0].workflow_executions[-1]
|
||||
wfe.execution_status = "CLOSED"
|
||||
# /bad
|
||||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFResponseError, "WorkflowExecution=")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_with_task_already_completed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
conn.respond_activity_task_completed(activity_token)
|
||||
|
||||
conn.respond_activity_task_completed.when.called_with(
|
||||
activity_token
|
||||
).should.throw(SWFResponseError, "Unknown activity, scheduledEventId = 5")
|
||||
|
||||
|
||||
# RespondActivityTaskFailed endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_failed():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.respond_activity_task_failed(activity_token,
|
||||
reason="short reason",
|
||||
details="long details")
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskFailed")
|
||||
resp["events"][-2]["activityTaskFailedEventAttributes"].should.equal(
|
||||
{"reason": "short reason", "details": "long details",
|
||||
"scheduledEventId": 5, "startedEventId": 6}
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_activity_task_completed_with_wrong_token():
|
||||
# NB: we just test ONE failure case for RespondActivityTaskFailed
|
||||
# because the safeguards are shared with RespondActivityTaskCompleted, so
|
||||
# no need to retest everything end-to-end.
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task("test-domain", "activity-task-list")
|
||||
conn.respond_activity_task_failed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFResponseError, "Invalid token")
|
||||
|
||||
|
||||
# RecordActivityTaskHeartbeat endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
resp = conn.record_activity_task_heartbeat(activity_token)
|
||||
resp.should.equal({"cancelRequested": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat_with_wrong_token():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
|
||||
conn.record_activity_task_heartbeat.when.called_with(
|
||||
"bad-token", details="some progress details"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_record_activity_task_heartbeat_sets_details_in_case_of_timeout():
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
activity_token = conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list")["taskToken"]
|
||||
conn.record_activity_task_heartbeat(
|
||||
activity_token, details="some progress details")
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Activity Task Heartbeat timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskTimedOut")
|
||||
attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"]
|
||||
attrs["details"].should.equal("some progress details")
|
||||
|
|
|
|||
|
|
@ -1,134 +1,134 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
|
||||
# RegisterActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
types = conn.list_activity_types("test-domain", "REGISTERED")
|
||||
actype = types["typeInfos"][0]
|
||||
actype["activityType"]["name"].should.equal("test-activity")
|
||||
actype["activityType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", 12
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListActivityTypes endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_activity_types():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "b-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "a-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "c-test-activity", "v1.0")
|
||||
|
||||
all_activity_types = conn.list_activity_types("test-domain", "REGISTERED")
|
||||
names = [activity_type["activityType"]["name"]
|
||||
for activity_type in all_activity_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["a-test-activity", "b-test-activity", "c-test-activity"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_activity_types_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "b-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "a-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "c-test-activity", "v1.0")
|
||||
|
||||
all_activity_types = conn.list_activity_types("test-domain", "REGISTERED",
|
||||
reverse_order=True)
|
||||
names = [activity_type["activityType"]["name"]
|
||||
for activity_type in all_activity_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["c-test-activity", "b-test-activity", "a-test-activity"])
|
||||
|
||||
|
||||
# DeprecateActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
actypes = conn.list_activity_types("test-domain", "DEPRECATED")
|
||||
actype = actypes["typeInfos"][0]
|
||||
actype["activityType"]["name"].should.equal("test-activity")
|
||||
actype["activityType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0",
|
||||
task_list="foo", default_task_heartbeat_timeout="32")
|
||||
|
||||
actype = conn.describe_activity_type(
|
||||
"test-domain", "test-activity", "v1.0")
|
||||
actype["configuration"]["defaultTaskList"]["name"].should.equal("foo")
|
||||
infos = actype["typeInfo"]
|
||||
infos["activityType"]["name"].should.equal("test-activity")
|
||||
infos["activityType"]["version"].should.equal("v1.0")
|
||||
infos["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.describe_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
|
||||
# RegisterActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
types = conn.list_activity_types("test-domain", "REGISTERED")
|
||||
actype = types["typeInfos"][0]
|
||||
actype["activityType"]["name"].should.equal("test-activity")
|
||||
actype["activityType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.register_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", 12
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListActivityTypes endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_activity_types():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "b-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "a-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "c-test-activity", "v1.0")
|
||||
|
||||
all_activity_types = conn.list_activity_types("test-domain", "REGISTERED")
|
||||
names = [activity_type["activityType"]["name"]
|
||||
for activity_type in all_activity_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["a-test-activity", "b-test-activity", "c-test-activity"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_activity_types_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "b-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "a-test-activity", "v1.0")
|
||||
conn.register_activity_type("test-domain", "c-test-activity", "v1.0")
|
||||
|
||||
all_activity_types = conn.list_activity_types("test-domain", "REGISTERED",
|
||||
reverse_order=True)
|
||||
names = [activity_type["activityType"]["name"]
|
||||
for activity_type in all_activity_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["c-test-activity", "b-test-activity", "a-test-activity"])
|
||||
|
||||
|
||||
# DeprecateActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
actypes = conn.list_activity_types("test-domain", "DEPRECATED")
|
||||
actype = actypes["typeInfos"][0]
|
||||
actype["activityType"]["name"].should.equal("test-activity")
|
||||
actype["activityType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0")
|
||||
conn.deprecate_activity_type("test-domain", "test-activity", "v1.0")
|
||||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "test-activity", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.deprecate_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeActivityType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.0",
|
||||
task_list="foo", default_task_heartbeat_timeout="32")
|
||||
|
||||
actype = conn.describe_activity_type(
|
||||
"test-domain", "test-activity", "v1.0")
|
||||
actype["configuration"]["defaultTaskList"]["name"].should.equal("foo")
|
||||
infos = actype["typeInfo"]
|
||||
infos["activityType"]["name"].should.equal("test-activity")
|
||||
infos["activityType"]["version"].should.equal("v1.0")
|
||||
infos["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_activity_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.describe_activity_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
|
|
@ -1,342 +1,342 @@
|
|||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.swf import swf_backend
|
||||
|
||||
from ..utils import setup_workflow
|
||||
|
||||
|
||||
# PollForDecisionTask endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_when_one():
|
||||
conn = setup_workflow()
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted", "DecisionTaskScheduled"])
|
||||
|
||||
resp = conn.poll_for_decision_task(
|
||||
"test-domain", "queue", identity="srv01")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled", "DecisionTaskStarted"])
|
||||
|
||||
resp[
|
||||
"events"][-1]["decisionTaskStartedEventAttributes"]["identity"].should.equal("srv01")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_when_none():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
# this is the DecisionTask representation you get from the real SWF
|
||||
# after waiting 60s when there's no decision to be taken
|
||||
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_on_non_existent_queue():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "non-existent-queue")
|
||||
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_with_reverse_order():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task(
|
||||
"test-domain", "queue", reverse_order=True)
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(
|
||||
["DecisionTaskStarted", "DecisionTaskScheduled", "WorkflowExecutionStarted"])
|
||||
|
||||
|
||||
# CountPendingDecisionTasks endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "queue")
|
||||
resp.should.equal({"count": 1, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_on_non_existent_task_list():
|
||||
conn = setup_workflow()
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "non-existent")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_after_decision_completes():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed(resp["taskToken"])
|
||||
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "queue")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
# RespondDecisionTaskCompleted endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_no_decision():
|
||||
conn = setup_workflow()
|
||||
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token,
|
||||
execution_context="free-form context",
|
||||
)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
])
|
||||
evt = resp["events"][-1]
|
||||
evt["decisionTaskCompletedEventAttributes"].should.equal({
|
||||
"executionContext": "free-form context",
|
||||
"scheduledEventId": 2,
|
||||
"startedEventId": 3,
|
||||
})
|
||||
|
||||
resp = conn.describe_workflow_execution(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["latestExecutionContext"].should.equal("free-form context")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_wrong_token():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_on_close_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
# bad: we're closing workflow execution manually, but endpoints are not
|
||||
# coded for now..
|
||||
wfe = swf_backend.domains[0].workflow_executions[-1]
|
||||
wfe.execution_status = "CLOSED"
|
||||
# /bad
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_task_already_completed():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
conn.respond_decision_task_completed(task_token)
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_complete_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "CompleteWorkflowExecution",
|
||||
"completeWorkflowExecutionDecisionAttributes": {"result": "foo bar"}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"WorkflowExecutionCompleted",
|
||||
])
|
||||
resp["events"][-1]["workflowExecutionCompletedEventAttributes"][
|
||||
"result"].should.equal("foo bar")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_close_decision_not_last():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "CompleteWorkflowExecution"},
|
||||
{"decisionType": "WeDontCare"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(SWFResponseError, r"Close must be last decision in list")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_invalid_decision_type():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "BadDecisionType"},
|
||||
{"decisionType": "CompleteWorkflowExecution"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_missing_attributes():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{
|
||||
"decisionType": "should trigger even with incorrect decision type",
|
||||
"startTimerDecisionAttributes": {}
|
||||
},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' "
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_missing_attributes_totally():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "StartTimer"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' "
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_fail_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "FailWorkflowExecution",
|
||||
"failWorkflowExecutionDecisionAttributes": {"reason": "my rules", "details": "foo"}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"WorkflowExecutionFailed",
|
||||
])
|
||||
attrs = resp["events"][-1]["workflowExecutionFailedEventAttributes"]
|
||||
attrs["reason"].should.equal("my rules")
|
||||
attrs["details"].should.equal("foo")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
@freeze_time("2015-01-01 12:00:00")
|
||||
def test_respond_decision_task_completed_with_schedule_activity_task():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "ScheduleActivityTask",
|
||||
"scheduleActivityTaskDecisionAttributes": {
|
||||
"activityId": "my-activity-001",
|
||||
"activityType": {
|
||||
"name": "test-activity",
|
||||
"version": "v1.1"
|
||||
},
|
||||
"heartbeatTimeout": "60",
|
||||
"input": "123",
|
||||
"taskList": {
|
||||
"name": "my-task-list"
|
||||
},
|
||||
}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"ActivityTaskScheduled",
|
||||
])
|
||||
resp["events"][-1]["activityTaskScheduledEventAttributes"].should.equal({
|
||||
"decisionTaskCompletedEventId": 4,
|
||||
"activityId": "my-activity-001",
|
||||
"activityType": {
|
||||
"name": "test-activity",
|
||||
"version": "v1.1",
|
||||
},
|
||||
"heartbeatTimeout": "60",
|
||||
"input": "123",
|
||||
"taskList": {
|
||||
"name": "my-task-list"
|
||||
},
|
||||
})
|
||||
|
||||
resp = conn.describe_workflow_execution(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["latestActivityTaskTimestamp"].should.equal(1420113600.0)
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.swf import swf_backend
|
||||
|
||||
from ..utils import setup_workflow
|
||||
|
||||
|
||||
# PollForDecisionTask endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_when_one():
|
||||
conn = setup_workflow()
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted", "DecisionTaskScheduled"])
|
||||
|
||||
resp = conn.poll_for_decision_task(
|
||||
"test-domain", "queue", identity="srv01")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled", "DecisionTaskStarted"])
|
||||
|
||||
resp[
|
||||
"events"][-1]["decisionTaskStartedEventAttributes"]["identity"].should.equal("srv01")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_when_none():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
# this is the DecisionTask representation you get from the real SWF
|
||||
# after waiting 60s when there's no decision to be taken
|
||||
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_on_non_existent_queue():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "non-existent-queue")
|
||||
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_poll_for_decision_task_with_reverse_order():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task(
|
||||
"test-domain", "queue", reverse_order=True)
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(
|
||||
["DecisionTaskStarted", "DecisionTaskScheduled", "WorkflowExecutionStarted"])
|
||||
|
||||
|
||||
# CountPendingDecisionTasks endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "queue")
|
||||
resp.should.equal({"count": 1, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_on_non_existent_task_list():
|
||||
conn = setup_workflow()
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "non-existent")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_count_pending_decision_tasks_after_decision_completes():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed(resp["taskToken"])
|
||||
|
||||
resp = conn.count_pending_decision_tasks("test-domain", "queue")
|
||||
resp.should.equal({"count": 0, "truncated": False})
|
||||
|
||||
|
||||
# RespondDecisionTaskCompleted endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_no_decision():
|
||||
conn = setup_workflow()
|
||||
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token,
|
||||
execution_context="free-form context",
|
||||
)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
])
|
||||
evt = resp["events"][-1]
|
||||
evt["decisionTaskCompletedEventAttributes"].should.equal({
|
||||
"executionContext": "free-form context",
|
||||
"scheduledEventId": 2,
|
||||
"startedEventId": 3,
|
||||
})
|
||||
|
||||
resp = conn.describe_workflow_execution(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["latestExecutionContext"].should.equal("free-form context")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_wrong_token():
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
"not-a-correct-token"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_on_close_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
# bad: we're closing workflow execution manually, but endpoints are not
|
||||
# coded for now..
|
||||
wfe = swf_backend.domains[0].workflow_executions[-1]
|
||||
wfe.execution_status = "CLOSED"
|
||||
# /bad
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_task_already_completed():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
conn.respond_decision_task_completed(task_token)
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_complete_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "CompleteWorkflowExecution",
|
||||
"completeWorkflowExecutionDecisionAttributes": {"result": "foo bar"}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"WorkflowExecutionCompleted",
|
||||
])
|
||||
resp["events"][-1]["workflowExecutionCompletedEventAttributes"][
|
||||
"result"].should.equal("foo bar")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_close_decision_not_last():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "CompleteWorkflowExecution"},
|
||||
{"decisionType": "WeDontCare"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(SWFResponseError, r"Close must be last decision in list")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_invalid_decision_type():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "BadDecisionType"},
|
||||
{"decisionType": "CompleteWorkflowExecution"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_missing_attributes():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{
|
||||
"decisionType": "should trigger even with incorrect decision type",
|
||||
"startTimerDecisionAttributes": {}
|
||||
},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' "
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_missing_attributes_totally():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [
|
||||
{"decisionType": "StartTimer"},
|
||||
]
|
||||
|
||||
conn.respond_decision_task_completed.when.called_with(
|
||||
task_token, decisions=decisions
|
||||
).should.throw(
|
||||
SWFResponseError,
|
||||
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' "
|
||||
r"failed to satisfy constraint: Member must not be null"
|
||||
)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_respond_decision_task_completed_with_fail_workflow_execution():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "FailWorkflowExecution",
|
||||
"failWorkflowExecutionDecisionAttributes": {"reason": "my rules", "details": "foo"}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"WorkflowExecutionFailed",
|
||||
])
|
||||
attrs = resp["events"][-1]["workflowExecutionFailedEventAttributes"]
|
||||
attrs["reason"].should.equal("my rules")
|
||||
attrs["details"].should.equal("foo")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
@freeze_time("2015-01-01 12:00:00")
|
||||
def test_respond_decision_task_completed_with_schedule_activity_task():
|
||||
conn = setup_workflow()
|
||||
resp = conn.poll_for_decision_task("test-domain", "queue")
|
||||
task_token = resp["taskToken"]
|
||||
|
||||
decisions = [{
|
||||
"decisionType": "ScheduleActivityTask",
|
||||
"scheduleActivityTaskDecisionAttributes": {
|
||||
"activityId": "my-activity-001",
|
||||
"activityType": {
|
||||
"name": "test-activity",
|
||||
"version": "v1.1"
|
||||
},
|
||||
"heartbeatTimeout": "60",
|
||||
"input": "123",
|
||||
"taskList": {
|
||||
"name": "my-task-list"
|
||||
},
|
||||
}
|
||||
}]
|
||||
resp = conn.respond_decision_task_completed(
|
||||
task_token, decisions=decisions)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal([
|
||||
"WorkflowExecutionStarted",
|
||||
"DecisionTaskScheduled",
|
||||
"DecisionTaskStarted",
|
||||
"DecisionTaskCompleted",
|
||||
"ActivityTaskScheduled",
|
||||
])
|
||||
resp["events"][-1]["activityTaskScheduledEventAttributes"].should.equal({
|
||||
"decisionTaskCompletedEventId": 4,
|
||||
"activityId": "my-activity-001",
|
||||
"activityType": {
|
||||
"name": "test-activity",
|
||||
"version": "v1.1",
|
||||
},
|
||||
"heartbeatTimeout": "60",
|
||||
"input": "123",
|
||||
"taskList": {
|
||||
"name": "my-task-list"
|
||||
},
|
||||
})
|
||||
|
||||
resp = conn.describe_workflow_execution(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["latestActivityTaskTimestamp"].should.equal(1420113600.0)
|
||||
|
|
|
|||
|
|
@ -1,119 +1,119 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
|
||||
# RegisterDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED")
|
||||
domain = all_domains["domainInfos"][0]
|
||||
|
||||
domain["name"].should.equal("test-domain")
|
||||
domain["status"].should.equal("REGISTERED")
|
||||
domain["description"].should.equal("A test domain")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", "60", description="A test domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", 60, description="A test domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListDomains endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_domains_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("b-test-domain", "60")
|
||||
conn.register_domain("a-test-domain", "60")
|
||||
conn.register_domain("c-test-domain", "60")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED")
|
||||
names = [domain["name"] for domain in all_domains["domainInfos"]]
|
||||
names.should.equal(["a-test-domain", "b-test-domain", "c-test-domain"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_domains_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("b-test-domain", "60")
|
||||
conn.register_domain("a-test-domain", "60")
|
||||
conn.register_domain("c-test-domain", "60")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED", reverse_order=True)
|
||||
names = [domain["name"] for domain in all_domains["domainInfos"]]
|
||||
names.should.equal(["c-test-domain", "b-test-domain", "a-test-domain"])
|
||||
|
||||
|
||||
# DeprecateDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
conn.deprecate_domain("test-domain")
|
||||
|
||||
all_domains = conn.list_domains("DEPRECATED")
|
||||
domain = all_domains["domainInfos"][0]
|
||||
|
||||
domain["name"].should.equal("test-domain")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
conn.deprecate_domain("test-domain")
|
||||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"test-domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
domain = conn.describe_domain("test-domain")
|
||||
domain["configuration"][
|
||||
"workflowExecutionRetentionPeriodInDays"].should.equal("60")
|
||||
domain["domainInfo"]["description"].should.equal("A test domain")
|
||||
domain["domainInfo"]["name"].should.equal("test-domain")
|
||||
domain["domainInfo"]["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.describe_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFResponseError)
|
||||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
|
||||
# RegisterDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED")
|
||||
domain = all_domains["domainInfos"][0]
|
||||
|
||||
domain["name"].should.equal("test-domain")
|
||||
domain["status"].should.equal("REGISTERED")
|
||||
domain["description"].should.equal("A test domain")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", "60", description="A test domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.register_domain.when.called_with(
|
||||
"test-domain", 60, description="A test domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListDomains endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_domains_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("b-test-domain", "60")
|
||||
conn.register_domain("a-test-domain", "60")
|
||||
conn.register_domain("c-test-domain", "60")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED")
|
||||
names = [domain["name"] for domain in all_domains["domainInfos"]]
|
||||
names.should.equal(["a-test-domain", "b-test-domain", "c-test-domain"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_domains_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("b-test-domain", "60")
|
||||
conn.register_domain("a-test-domain", "60")
|
||||
conn.register_domain("c-test-domain", "60")
|
||||
|
||||
all_domains = conn.list_domains("REGISTERED", reverse_order=True)
|
||||
names = [domain["name"] for domain in all_domains["domainInfos"]]
|
||||
names.should.equal(["c-test-domain", "b-test-domain", "a-test-domain"])
|
||||
|
||||
|
||||
# DeprecateDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
conn.deprecate_domain("test-domain")
|
||||
|
||||
all_domains = conn.list_domains("DEPRECATED")
|
||||
domain = all_domains["domainInfos"][0]
|
||||
|
||||
domain["name"].should.equal("test-domain")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
conn.deprecate_domain("test-domain")
|
||||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"test-domain"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.deprecate_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeDomain endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60", description="A test domain")
|
||||
|
||||
domain = conn.describe_domain("test-domain")
|
||||
domain["configuration"][
|
||||
"workflowExecutionRetentionPeriodInDays"].should.equal("60")
|
||||
domain["domainInfo"]["description"].should.equal("A test domain")
|
||||
domain["domainInfo"]["name"].should.equal("test-domain")
|
||||
domain["domainInfo"]["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_domain():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
||||
conn.describe_domain.when.called_with(
|
||||
"non-existent"
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
|
|
@ -1,110 +1,110 @@
|
|||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
|
||||
|
||||
# Activity Task Heartbeat timeout
|
||||
# Default value in workflow helpers: 5 mins
|
||||
@mock_swf_deprecated
|
||||
def test_activity_task_heartbeat_timeout():
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list", identity="surprise")
|
||||
|
||||
with freeze_time("2015-01-01 12:04:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-1]["eventType"].should.equal("ActivityTaskStarted")
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Activity Task Heartbeat timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskTimedOut")
|
||||
attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"]
|
||||
attrs["timeoutType"].should.equal("HEARTBEAT")
|
||||
# checks that event has been emitted at 12:05:00, not 12:05:30
|
||||
resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
|
||||
|
||||
resp["events"][-1]["eventType"].should.equal("DecisionTaskScheduled")
|
||||
|
||||
|
||||
# Decision Task Start to Close timeout
|
||||
# Default value in workflow helpers: 5 mins
|
||||
@mock_swf_deprecated
|
||||
def test_decision_task_start_to_close_timeout():
|
||||
pass
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
|
||||
|
||||
with freeze_time("2015-01-01 12:04:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled", "DecisionTaskStarted"]
|
||||
)
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Decision Task Start to Close timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled", "DecisionTaskStarted",
|
||||
"DecisionTaskTimedOut", "DecisionTaskScheduled"]
|
||||
)
|
||||
attrs = resp["events"][-2]["decisionTaskTimedOutEventAttributes"]
|
||||
attrs.should.equal({
|
||||
"scheduledEventId": 2, "startedEventId": 3, "timeoutType": "START_TO_CLOSE"
|
||||
})
|
||||
# checks that event has been emitted at 12:05:00, not 12:05:30
|
||||
resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
|
||||
|
||||
|
||||
# Workflow Execution Start to Close timeout
|
||||
# Default value in workflow helpers: 2 hours
|
||||
@mock_swf_deprecated
|
||||
def test_workflow_execution_start_to_close_timeout():
|
||||
pass
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
|
||||
with freeze_time("2015-01-01 13:59:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled"]
|
||||
)
|
||||
|
||||
with freeze_time("2015-01-01 14:00:30"):
|
||||
# => Workflow Execution Start to Close timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled",
|
||||
"WorkflowExecutionTimedOut"]
|
||||
)
|
||||
attrs = resp["events"][-1]["workflowExecutionTimedOutEventAttributes"]
|
||||
attrs.should.equal({
|
||||
"childPolicy": "ABANDON", "timeoutType": "START_TO_CLOSE"
|
||||
})
|
||||
# checks that event has been emitted at 14:00:00, not 14:00:30
|
||||
resp["events"][-1]["eventTimestamp"].should.equal(1420120800.0)
|
||||
from freezegun import freeze_time
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
|
||||
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
|
||||
|
||||
# Activity Task Heartbeat timeout
|
||||
# Default value in workflow helpers: 5 mins
|
||||
@mock_swf_deprecated
|
||||
def test_activity_task_heartbeat_timeout():
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
decision_token = conn.poll_for_decision_task(
|
||||
"test-domain", "queue")["taskToken"]
|
||||
conn.respond_decision_task_completed(decision_token, decisions=[
|
||||
SCHEDULE_ACTIVITY_TASK_DECISION
|
||||
])
|
||||
conn.poll_for_activity_task(
|
||||
"test-domain", "activity-task-list", identity="surprise")
|
||||
|
||||
with freeze_time("2015-01-01 12:04:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
resp["events"][-1]["eventType"].should.equal("ActivityTaskStarted")
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Activity Task Heartbeat timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
resp["events"][-2]["eventType"].should.equal("ActivityTaskTimedOut")
|
||||
attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"]
|
||||
attrs["timeoutType"].should.equal("HEARTBEAT")
|
||||
# checks that event has been emitted at 12:05:00, not 12:05:30
|
||||
resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
|
||||
|
||||
resp["events"][-1]["eventType"].should.equal("DecisionTaskScheduled")
|
||||
|
||||
|
||||
# Decision Task Start to Close timeout
|
||||
# Default value in workflow helpers: 5 mins
|
||||
@mock_swf_deprecated
|
||||
def test_decision_task_start_to_close_timeout():
|
||||
pass
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
|
||||
|
||||
with freeze_time("2015-01-01 12:04:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled", "DecisionTaskStarted"]
|
||||
)
|
||||
|
||||
with freeze_time("2015-01-01 12:05:30"):
|
||||
# => Decision Task Start to Close timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled", "DecisionTaskStarted",
|
||||
"DecisionTaskTimedOut", "DecisionTaskScheduled"]
|
||||
)
|
||||
attrs = resp["events"][-2]["decisionTaskTimedOutEventAttributes"]
|
||||
attrs.should.equal({
|
||||
"scheduledEventId": 2, "startedEventId": 3, "timeoutType": "START_TO_CLOSE"
|
||||
})
|
||||
# checks that event has been emitted at 12:05:00, not 12:05:30
|
||||
resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
|
||||
|
||||
|
||||
# Workflow Execution Start to Close timeout
|
||||
# Default value in workflow helpers: 2 hours
|
||||
@mock_swf_deprecated
|
||||
def test_workflow_execution_start_to_close_timeout():
|
||||
pass
|
||||
with freeze_time("2015-01-01 12:00:00"):
|
||||
conn = setup_workflow()
|
||||
|
||||
with freeze_time("2015-01-01 13:59:30"):
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled"]
|
||||
)
|
||||
|
||||
with freeze_time("2015-01-01 14:00:30"):
|
||||
# => Workflow Execution Start to Close timeout reached!!
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", conn.run_id, "uid-abcd1234")
|
||||
|
||||
event_types = [evt["eventType"] for evt in resp["events"]]
|
||||
event_types.should.equal(
|
||||
["WorkflowExecutionStarted", "DecisionTaskScheduled",
|
||||
"WorkflowExecutionTimedOut"]
|
||||
)
|
||||
attrs = resp["events"][-1]["workflowExecutionTimedOutEventAttributes"]
|
||||
attrs.should.equal({
|
||||
"childPolicy": "ABANDON", "timeoutType": "START_TO_CLOSE"
|
||||
})
|
||||
# checks that event has been emitted at 14:00:00, not 14:00:30
|
||||
resp["events"][-1]["eventTimestamp"].should.equal(1420120800.0)
|
||||
|
|
|
|||
|
|
@ -1,262 +1,262 @@
|
|||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import sure # noqa
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.core.utils import unix_time
|
||||
|
||||
|
||||
# Utils
|
||||
@mock_swf_deprecated
|
||||
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",
|
||||
task_list="queue", default_child_policy="TERMINATE",
|
||||
default_execution_start_to_close_timeout="300",
|
||||
default_task_start_to_close_timeout="300",
|
||||
)
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.1")
|
||||
return conn
|
||||
|
||||
|
||||
# StartWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
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_deprecated
|
||||
def test_signal_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
wfe = conn.signal_workflow_execution(
|
||||
"test-domain", "my_signal", "uid-abcd1234", "my_input", run_id)
|
||||
|
||||
wfe = conn.describe_workflow_execution(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
|
||||
wfe["openCounts"]["openDecisionTasks"].should.equal(2)
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_start_already_started_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_start_workflow_execution_on_deprecated_type():
|
||||
conn = setup_swf_environment()
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
wfe = conn.describe_workflow_execution(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
wfe["executionInfo"]["execution"][
|
||||
"workflowId"].should.equal("uid-abcd1234")
|
||||
wfe["executionInfo"]["executionStatus"].should.equal("OPEN")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
|
||||
conn.describe_workflow_execution.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# GetWorkflowExecutionHistory endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted", "DecisionTaskScheduled"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history_with_reverse_order():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
resp = conn.get_workflow_execution_history("test-domain", run_id, "uid-abcd1234",
|
||||
reverse_order=True)
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["DecisionTaskScheduled", "WorkflowExecutionStarted"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history_on_non_existent_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
|
||||
conn.get_workflow_execution_history.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListOpenWorkflowExecutions endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_open_workflow_executions():
|
||||
conn = setup_swf_environment()
|
||||
# One open workflow execution
|
||||
conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd1234', 'test-workflow', 'v1.0'
|
||||
)
|
||||
# One closed workflow execution to make sure it isn't displayed
|
||||
run_id = conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'
|
||||
)['runId']
|
||||
conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',
|
||||
details='some details',
|
||||
reason='a more complete reason',
|
||||
run_id=run_id)
|
||||
|
||||
yesterday = datetime.utcnow() - timedelta(days=1)
|
||||
oldest_date = unix_time(yesterday)
|
||||
response = conn.list_open_workflow_executions('test-domain',
|
||||
oldest_date,
|
||||
workflow_id='test-workflow')
|
||||
execution_infos = response['executionInfos']
|
||||
len(execution_infos).should.equal(1)
|
||||
open_workflow = execution_infos[0]
|
||||
open_workflow['workflowType'].should.equal({'version': 'v1.0',
|
||||
'name': 'test-workflow'})
|
||||
open_workflow.should.contain('startTimestamp')
|
||||
open_workflow['execution']['workflowId'].should.equal('uid-abcd1234')
|
||||
open_workflow['execution'].should.contain('runId')
|
||||
open_workflow['cancelRequested'].should.be(False)
|
||||
open_workflow['executionStatus'].should.equal('OPEN')
|
||||
|
||||
|
||||
# ListClosedWorkflowExecutions endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_closed_workflow_executions():
|
||||
conn = setup_swf_environment()
|
||||
# Leave one workflow execution open to make sure it isn't displayed
|
||||
conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd1234', 'test-workflow', 'v1.0'
|
||||
)
|
||||
# One closed workflow execution
|
||||
run_id = conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'
|
||||
)['runId']
|
||||
conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',
|
||||
details='some details',
|
||||
reason='a more complete reason',
|
||||
run_id=run_id)
|
||||
|
||||
yesterday = datetime.utcnow() - timedelta(days=1)
|
||||
oldest_date = unix_time(yesterday)
|
||||
response = conn.list_closed_workflow_executions(
|
||||
'test-domain',
|
||||
start_oldest_date=oldest_date,
|
||||
workflow_id='test-workflow')
|
||||
execution_infos = response['executionInfos']
|
||||
len(execution_infos).should.equal(1)
|
||||
open_workflow = execution_infos[0]
|
||||
open_workflow['workflowType'].should.equal({'version': 'v1.0',
|
||||
'name': 'test-workflow'})
|
||||
open_workflow.should.contain('startTimestamp')
|
||||
open_workflow['execution']['workflowId'].should.equal('uid-abcd12345')
|
||||
open_workflow['execution'].should.contain('runId')
|
||||
open_workflow['cancelRequested'].should.be(False)
|
||||
open_workflow['executionStatus'].should.equal('CLOSED')
|
||||
|
||||
|
||||
# TerminateWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_terminate_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
run_id = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
)["runId"]
|
||||
|
||||
resp = conn.terminate_workflow_execution("test-domain", "uid-abcd1234",
|
||||
details="some details",
|
||||
reason="a more complete reason",
|
||||
run_id=run_id)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
evt = resp["events"][-1]
|
||||
evt["eventType"].should.equal("WorkflowExecutionTerminated")
|
||||
attrs = evt["workflowExecutionTerminatedEventAttributes"]
|
||||
attrs["details"].should.equal("some details")
|
||||
attrs["reason"].should.equal("a more complete reason")
|
||||
attrs["cause"].should.equal("OPERATOR_INITIATED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_terminate_workflow_execution_with_wrong_workflow_or_run_id():
|
||||
conn = setup_swf_environment()
|
||||
run_id = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
)["runId"]
|
||||
|
||||
# terminate workflow execution
|
||||
conn.terminate_workflow_execution("test-domain", "uid-abcd1234")
|
||||
|
||||
# already closed, with run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", run_id=run_id
|
||||
).should.throw(
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
|
||||
# already closed, without run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234"
|
||||
).should.throw(
|
||||
SWFResponseError, "Unknown execution, workflowId = uid-abcd1234"
|
||||
)
|
||||
|
||||
# wrong workflow id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-non-existent"
|
||||
).should.throw(
|
||||
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(
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
import boto
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import sure # noqa
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises # noqa
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from moto.core.utils import unix_time
|
||||
|
||||
|
||||
# Utils
|
||||
@mock_swf_deprecated
|
||||
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",
|
||||
task_list="queue", default_child_policy="TERMINATE",
|
||||
default_execution_start_to_close_timeout="300",
|
||||
default_task_start_to_close_timeout="300",
|
||||
)
|
||||
conn.register_activity_type("test-domain", "test-activity", "v1.1")
|
||||
return conn
|
||||
|
||||
|
||||
# StartWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
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_deprecated
|
||||
def test_signal_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
wfe = conn.signal_workflow_execution(
|
||||
"test-domain", "my_signal", "uid-abcd1234", "my_input", run_id)
|
||||
|
||||
wfe = conn.describe_workflow_execution(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
|
||||
wfe["openCounts"]["openDecisionTasks"].should.equal(2)
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_start_already_started_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_start_workflow_execution_on_deprecated_type():
|
||||
conn = setup_swf_environment()
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.start_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
wfe = conn.describe_workflow_execution(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
wfe["executionInfo"]["execution"][
|
||||
"workflowId"].should.equal("uid-abcd1234")
|
||||
wfe["executionInfo"]["executionStatus"].should.equal("OPEN")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
|
||||
conn.describe_workflow_execution.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# GetWorkflowExecutionHistory endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["WorkflowExecutionStarted", "DecisionTaskScheduled"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history_with_reverse_order():
|
||||
conn = setup_swf_environment()
|
||||
hsh = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0")
|
||||
run_id = hsh["runId"]
|
||||
|
||||
resp = conn.get_workflow_execution_history("test-domain", run_id, "uid-abcd1234",
|
||||
reverse_order=True)
|
||||
types = [evt["eventType"] for evt in resp["events"]]
|
||||
types.should.equal(["DecisionTaskScheduled", "WorkflowExecutionStarted"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_get_workflow_execution_history_on_non_existent_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
|
||||
conn.get_workflow_execution_history.when.called_with(
|
||||
"test-domain", "wrong-run-id", "wrong-workflow-id"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListOpenWorkflowExecutions endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_open_workflow_executions():
|
||||
conn = setup_swf_environment()
|
||||
# One open workflow execution
|
||||
conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd1234', 'test-workflow', 'v1.0'
|
||||
)
|
||||
# One closed workflow execution to make sure it isn't displayed
|
||||
run_id = conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'
|
||||
)['runId']
|
||||
conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',
|
||||
details='some details',
|
||||
reason='a more complete reason',
|
||||
run_id=run_id)
|
||||
|
||||
yesterday = datetime.utcnow() - timedelta(days=1)
|
||||
oldest_date = unix_time(yesterday)
|
||||
response = conn.list_open_workflow_executions('test-domain',
|
||||
oldest_date,
|
||||
workflow_id='test-workflow')
|
||||
execution_infos = response['executionInfos']
|
||||
len(execution_infos).should.equal(1)
|
||||
open_workflow = execution_infos[0]
|
||||
open_workflow['workflowType'].should.equal({'version': 'v1.0',
|
||||
'name': 'test-workflow'})
|
||||
open_workflow.should.contain('startTimestamp')
|
||||
open_workflow['execution']['workflowId'].should.equal('uid-abcd1234')
|
||||
open_workflow['execution'].should.contain('runId')
|
||||
open_workflow['cancelRequested'].should.be(False)
|
||||
open_workflow['executionStatus'].should.equal('OPEN')
|
||||
|
||||
|
||||
# ListClosedWorkflowExecutions endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_closed_workflow_executions():
|
||||
conn = setup_swf_environment()
|
||||
# Leave one workflow execution open to make sure it isn't displayed
|
||||
conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd1234', 'test-workflow', 'v1.0'
|
||||
)
|
||||
# One closed workflow execution
|
||||
run_id = conn.start_workflow_execution(
|
||||
'test-domain', 'uid-abcd12345', 'test-workflow', 'v1.0'
|
||||
)['runId']
|
||||
conn.terminate_workflow_execution('test-domain', 'uid-abcd12345',
|
||||
details='some details',
|
||||
reason='a more complete reason',
|
||||
run_id=run_id)
|
||||
|
||||
yesterday = datetime.utcnow() - timedelta(days=1)
|
||||
oldest_date = unix_time(yesterday)
|
||||
response = conn.list_closed_workflow_executions(
|
||||
'test-domain',
|
||||
start_oldest_date=oldest_date,
|
||||
workflow_id='test-workflow')
|
||||
execution_infos = response['executionInfos']
|
||||
len(execution_infos).should.equal(1)
|
||||
open_workflow = execution_infos[0]
|
||||
open_workflow['workflowType'].should.equal({'version': 'v1.0',
|
||||
'name': 'test-workflow'})
|
||||
open_workflow.should.contain('startTimestamp')
|
||||
open_workflow['execution']['workflowId'].should.equal('uid-abcd12345')
|
||||
open_workflow['execution'].should.contain('runId')
|
||||
open_workflow['cancelRequested'].should.be(False)
|
||||
open_workflow['executionStatus'].should.equal('CLOSED')
|
||||
|
||||
|
||||
# TerminateWorkflowExecution endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_terminate_workflow_execution():
|
||||
conn = setup_swf_environment()
|
||||
run_id = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
)["runId"]
|
||||
|
||||
resp = conn.terminate_workflow_execution("test-domain", "uid-abcd1234",
|
||||
details="some details",
|
||||
reason="a more complete reason",
|
||||
run_id=run_id)
|
||||
resp.should.be.none
|
||||
|
||||
resp = conn.get_workflow_execution_history(
|
||||
"test-domain", run_id, "uid-abcd1234")
|
||||
evt = resp["events"][-1]
|
||||
evt["eventType"].should.equal("WorkflowExecutionTerminated")
|
||||
attrs = evt["workflowExecutionTerminatedEventAttributes"]
|
||||
attrs["details"].should.equal("some details")
|
||||
attrs["reason"].should.equal("a more complete reason")
|
||||
attrs["cause"].should.equal("OPERATOR_INITIATED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_terminate_workflow_execution_with_wrong_workflow_or_run_id():
|
||||
conn = setup_swf_environment()
|
||||
run_id = conn.start_workflow_execution(
|
||||
"test-domain", "uid-abcd1234", "test-workflow", "v1.0"
|
||||
)["runId"]
|
||||
|
||||
# terminate workflow execution
|
||||
conn.terminate_workflow_execution("test-domain", "uid-abcd1234")
|
||||
|
||||
# already closed, with run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234", run_id=run_id
|
||||
).should.throw(
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
|
||||
# already closed, without run_id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-abcd1234"
|
||||
).should.throw(
|
||||
SWFResponseError, "Unknown execution, workflowId = uid-abcd1234"
|
||||
)
|
||||
|
||||
# wrong workflow id
|
||||
conn.terminate_workflow_execution.when.called_with(
|
||||
"test-domain", "uid-non-existent"
|
||||
).should.throw(
|
||||
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(
|
||||
SWFResponseError, "WorkflowExecution=[workflowId=uid-abcd1234, runId="
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,137 +1,137 @@
|
|||
import sure
|
||||
import boto
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
|
||||
|
||||
# RegisterWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
types = conn.list_workflow_types("test-domain", "REGISTERED")
|
||||
actype = types["typeInfos"][0]
|
||||
actype["workflowType"]["name"].should.equal("test-workflow")
|
||||
actype["workflowType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", 12
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListWorkflowTypes endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_workflow_types():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "b-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "a-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "c-test-workflow", "v1.0")
|
||||
|
||||
all_workflow_types = conn.list_workflow_types("test-domain", "REGISTERED")
|
||||
names = [activity_type["workflowType"]["name"]
|
||||
for activity_type in all_workflow_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["a-test-workflow", "b-test-workflow", "c-test-workflow"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_workflow_types_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "b-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "a-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "c-test-workflow", "v1.0")
|
||||
|
||||
all_workflow_types = conn.list_workflow_types("test-domain", "REGISTERED",
|
||||
reverse_order=True)
|
||||
names = [activity_type["workflowType"]["name"]
|
||||
for activity_type in all_workflow_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["c-test-workflow", "b-test-workflow", "a-test-workflow"])
|
||||
|
||||
|
||||
# DeprecateWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
actypes = conn.list_workflow_types("test-domain", "DEPRECATED")
|
||||
actype = actypes["typeInfos"][0]
|
||||
actype["workflowType"]["name"].should.equal("test-workflow")
|
||||
actype["workflowType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0",
|
||||
task_list="foo", default_child_policy="TERMINATE")
|
||||
|
||||
actype = conn.describe_workflow_type(
|
||||
"test-domain", "test-workflow", "v1.0")
|
||||
actype["configuration"]["defaultTaskList"]["name"].should.equal("foo")
|
||||
actype["configuration"]["defaultChildPolicy"].should.equal("TERMINATE")
|
||||
actype["configuration"].keys().should_not.contain(
|
||||
"defaultTaskStartToCloseTimeout")
|
||||
infos = actype["typeInfo"]
|
||||
infos["workflowType"]["name"].should.equal("test-workflow")
|
||||
infos["workflowType"]["version"].should.equal("v1.0")
|
||||
infos["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.describe_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
import sure
|
||||
import boto
|
||||
|
||||
from moto import mock_swf_deprecated
|
||||
from boto.swf.exceptions import SWFResponseError
|
||||
|
||||
|
||||
# RegisterWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_register_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
types = conn.list_workflow_types("test-domain", "REGISTERED")
|
||||
actype = types["typeInfos"][0]
|
||||
actype["workflowType"]["name"].should.equal("test-workflow")
|
||||
actype["workflowType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_already_existing_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_register_with_wrong_parameter_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.register_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", 12
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# ListWorkflowTypes endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_list_workflow_types():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "b-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "a-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "c-test-workflow", "v1.0")
|
||||
|
||||
all_workflow_types = conn.list_workflow_types("test-domain", "REGISTERED")
|
||||
names = [activity_type["workflowType"]["name"]
|
||||
for activity_type in all_workflow_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["a-test-workflow", "b-test-workflow", "c-test-workflow"])
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_list_workflow_types_reverse_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "b-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "a-test-workflow", "v1.0")
|
||||
conn.register_workflow_type("test-domain", "c-test-workflow", "v1.0")
|
||||
|
||||
all_workflow_types = conn.list_workflow_types("test-domain", "REGISTERED",
|
||||
reverse_order=True)
|
||||
names = [activity_type["workflowType"]["name"]
|
||||
for activity_type in all_workflow_types["typeInfos"]]
|
||||
names.should.equal(
|
||||
["c-test-workflow", "b-test-workflow", "a-test-workflow"])
|
||||
|
||||
|
||||
# DeprecateWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
actypes = conn.list_workflow_types("test-domain", "DEPRECATED")
|
||||
actype = actypes["typeInfos"][0]
|
||||
actype["workflowType"]["name"].should.equal("test-workflow")
|
||||
actype["workflowType"]["version"].should.equal("v1.0")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_already_deprecated_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
|
||||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "test-workflow", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_deprecate_non_existent_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.deprecate_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
||||
|
||||
# DescribeWorkflowType endpoint
|
||||
@mock_swf_deprecated
|
||||
def test_describe_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
conn.register_workflow_type("test-domain", "test-workflow", "v1.0",
|
||||
task_list="foo", default_child_policy="TERMINATE")
|
||||
|
||||
actype = conn.describe_workflow_type(
|
||||
"test-domain", "test-workflow", "v1.0")
|
||||
actype["configuration"]["defaultTaskList"]["name"].should.equal("foo")
|
||||
actype["configuration"]["defaultChildPolicy"].should.equal("TERMINATE")
|
||||
actype["configuration"].keys().should_not.contain(
|
||||
"defaultTaskStartToCloseTimeout")
|
||||
infos = actype["typeInfo"]
|
||||
infos["workflowType"]["name"].should.equal("test-workflow")
|
||||
infos["workflowType"]["version"].should.equal("v1.0")
|
||||
infos["status"].should.equal("REGISTERED")
|
||||
|
||||
|
||||
@mock_swf_deprecated
|
||||
def test_describe_non_existent_workflow_type():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
conn.register_domain("test-domain", "60")
|
||||
|
||||
conn.describe_workflow_type.when.called_with(
|
||||
"test-domain", "non-existent", "v1.0"
|
||||
).should.throw(SWFResponseError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue