Run black on moto & test directories.

This commit is contained in:
Asher Foa 2019-10-31 08:44:26 -07:00
commit 96e5b1993d
507 changed files with 52541 additions and 47814 deletions

View file

@ -14,18 +14,20 @@ def test_poll_for_decision_task_when_one():
conn = setup_workflow()
resp = conn.get_workflow_execution_history(
"test-domain", conn.run_id, "uid-abcd1234")
"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")
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"])
types.should.equal(
["WorkflowExecutionStarted", "DecisionTaskScheduled", "DecisionTaskStarted"]
)
resp[
"events"][-1]["decisionTaskStartedEventAttributes"]["identity"].should.equal("srv01")
resp["events"][-1]["decisionTaskStartedEventAttributes"]["identity"].should.equal(
"srv01"
)
@mock_swf_deprecated
@ -49,11 +51,11 @@ def test_poll_for_decision_task_on_non_existent_queue():
@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)
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"])
["DecisionTaskStarted", "DecisionTaskScheduled", "WorkflowExecutionStarted"]
)
# CountPendingDecisionTasks endpoint
@ -91,29 +93,32 @@ def test_respond_decision_task_completed_with_no_decision():
task_token = resp["taskToken"]
resp = conn.respond_decision_task_completed(
task_token,
execution_context="free-form context",
task_token, execution_context="free-form context"
)
resp.should.be.none
resp = conn.get_workflow_execution_history(
"test-domain", conn.run_id, "uid-abcd1234")
"test-domain", conn.run_id, "uid-abcd1234"
)
types = [evt["eventType"] for evt in resp["events"]]
types.should.equal([
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
])
types.should.equal(
[
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
]
)
evt = resp["events"][-1]
evt["decisionTaskCompletedEventAttributes"].should.equal({
"executionContext": "free-form context",
"scheduledEventId": 2,
"startedEventId": 3,
})
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 = conn.describe_workflow_execution("test-domain", conn.run_id, "uid-abcd1234")
resp["latestExecutionContext"].should.equal("free-form context")
@ -138,9 +143,9 @@ def test_respond_decision_task_completed_on_close_workflow_execution():
wfe.execution_status = "CLOSED"
# /bad
conn.respond_decision_task_completed.when.called_with(
task_token
).should.throw(SWFResponseError)
conn.respond_decision_task_completed.when.called_with(task_token).should.throw(
SWFResponseError
)
@mock_swf_deprecated
@ -150,9 +155,9 @@ def test_respond_decision_task_completed_with_task_already_completed():
task_token = resp["taskToken"]
conn.respond_decision_task_completed(task_token)
conn.respond_decision_task_completed.when.called_with(
task_token
).should.throw(SWFResponseError)
conn.respond_decision_task_completed.when.called_with(task_token).should.throw(
SWFResponseError
)
@mock_swf_deprecated
@ -161,26 +166,31 @@ def test_respond_decision_task_completed_with_complete_workflow_execution():
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)
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")
"test-domain", conn.run_id, "uid-abcd1234"
)
types = [evt["eventType"] for evt in resp["events"]]
types.should.equal([
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
"WorkflowExecutionCompleted",
])
types.should.equal(
[
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
"WorkflowExecutionCompleted",
]
)
resp["events"][-1]["workflowExecutionCompletedEventAttributes"][
"result"].should.equal("foo bar")
"result"
].should.equal("foo bar")
@mock_swf_deprecated
@ -211,9 +221,10 @@ def test_respond_decision_task_completed_with_invalid_decision_type():
]
conn.respond_decision_task_completed.when.called_with(
task_token, decisions=decisions).should.throw(
SWFResponseError,
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'"
task_token, decisions=decisions
).should.throw(
SWFResponseError,
r"Value 'BadDecisionType' at 'decisions.1.member.decisionType'",
)
@ -226,8 +237,8 @@ def test_respond_decision_task_completed_with_missing_attributes():
decisions = [
{
"decisionType": "should trigger even with incorrect decision type",
"startTimerDecisionAttributes": {}
},
"startTimerDecisionAttributes": {},
}
]
conn.respond_decision_task_completed.when.called_with(
@ -235,7 +246,7 @@ def test_respond_decision_task_completed_with_missing_attributes():
).should.throw(
SWFResponseError,
r"Value null at 'decisions.1.member.startTimerDecisionAttributes.timerId' "
r"failed to satisfy constraint: Member must not be null"
r"failed to satisfy constraint: Member must not be null",
)
@ -245,16 +256,14 @@ def test_respond_decision_task_completed_with_missing_attributes_totally():
resp = conn.poll_for_decision_task("test-domain", "queue")
task_token = resp["taskToken"]
decisions = [
{"decisionType": "StartTimer"},
]
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"
r"failed to satisfy constraint: Member must not be null",
)
@ -264,24 +273,31 @@ def test_respond_decision_task_completed_with_fail_workflow_execution():
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)
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")
"test-domain", conn.run_id, "uid-abcd1234"
)
types = [evt["eventType"] for evt in resp["events"]]
types.should.equal([
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
"WorkflowExecutionFailed",
])
types.should.equal(
[
"WorkflowExecutionStarted",
"DecisionTaskScheduled",
"DecisionTaskStarted",
"DecisionTaskCompleted",
"WorkflowExecutionFailed",
]
)
attrs = resp["events"][-1]["workflowExecutionFailedEventAttributes"]
attrs["reason"].should.equal("my rules")
attrs["details"].should.equal("foo")
@ -294,49 +310,44 @@ def test_respond_decision_task_completed_with_schedule_activity_task():
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"
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 = 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")
"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"
},
})
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 = conn.describe_workflow_execution("test-domain", conn.run_id, "uid-abcd1234")
resp["latestActivityTaskTimestamp"].should.equal(1420113600.0)