Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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_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_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
@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="
)
@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_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_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_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_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_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"