Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -147,6 +147,7 @@ def test_activity_task_cannot_change_state_on_closed_workflow_execution():
|
|||
)
|
||||
wfe.complete(123)
|
||||
|
||||
task.timeout.when.called_with(Timeout(task, 0, "foo")).should.throw(SWFWorkflowExecutionClosedError)
|
||||
task.timeout.when.called_with(Timeout(task, 0, "foo")).should.throw(
|
||||
SWFWorkflowExecutionClosedError)
|
||||
task.complete.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
|
||||
task.fail.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
|
||||
|
|
|
|||
|
|
@ -75,5 +75,6 @@ def test_decision_task_cannot_change_state_on_closed_workflow_execution():
|
|||
|
||||
wfe.complete(123)
|
||||
|
||||
task.timeout.when.called_with(Timeout(task, 0, "foo")).should.throw(SWFWorkflowExecutionClosedError)
|
||||
task.timeout.when.called_with(Timeout(task, 0, "foo")).should.throw(
|
||||
SWFWorkflowExecutionClosedError)
|
||||
task.complete.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ WorkflowExecution = namedtuple(
|
|||
|
||||
def test_domain_short_dict_representation():
|
||||
domain = Domain("foo", "52")
|
||||
domain.to_short_dict().should.equal({"name": "foo", "status": "REGISTERED"})
|
||||
domain.to_short_dict().should.equal(
|
||||
{"name": "foo", "status": "REGISTERED"})
|
||||
|
||||
domain.description = "foo bar"
|
||||
domain.to_short_dict()["description"].should.equal("foo bar")
|
||||
|
|
@ -67,16 +68,23 @@ def test_domain_decision_tasks():
|
|||
def test_domain_get_workflow_execution():
|
||||
domain = Domain("my-domain", "60")
|
||||
|
||||
wfe1 = WorkflowExecution(workflow_id="wf-id-1", run_id="run-id-1", execution_status="OPEN", open=True)
|
||||
wfe2 = WorkflowExecution(workflow_id="wf-id-1", run_id="run-id-2", execution_status="CLOSED", open=False)
|
||||
wfe3 = WorkflowExecution(workflow_id="wf-id-2", run_id="run-id-3", execution_status="OPEN", open=True)
|
||||
wfe4 = WorkflowExecution(workflow_id="wf-id-3", run_id="run-id-4", execution_status="CLOSED", open=False)
|
||||
wfe1 = WorkflowExecution(
|
||||
workflow_id="wf-id-1", run_id="run-id-1", execution_status="OPEN", open=True)
|
||||
wfe2 = WorkflowExecution(
|
||||
workflow_id="wf-id-1", run_id="run-id-2", execution_status="CLOSED", open=False)
|
||||
wfe3 = WorkflowExecution(
|
||||
workflow_id="wf-id-2", run_id="run-id-3", execution_status="OPEN", open=True)
|
||||
wfe4 = WorkflowExecution(
|
||||
workflow_id="wf-id-3", run_id="run-id-4", execution_status="CLOSED", open=False)
|
||||
domain.workflow_executions = [wfe1, wfe2, wfe3, wfe4]
|
||||
|
||||
# get workflow execution through workflow_id and run_id
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-1").should.equal(wfe1)
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-2").should.equal(wfe2)
|
||||
domain.get_workflow_execution("wf-id-3", run_id="run-id-4").should.equal(wfe4)
|
||||
domain.get_workflow_execution(
|
||||
"wf-id-1", run_id="run-id-1").should.equal(wfe1)
|
||||
domain.get_workflow_execution(
|
||||
"wf-id-1", run_id="run-id-2").should.equal(wfe2)
|
||||
domain.get_workflow_execution(
|
||||
"wf-id-3", run_id="run-id-4").should.equal(wfe4)
|
||||
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-1", run_id="non-existent"
|
||||
|
|
@ -98,7 +106,8 @@ def test_domain_get_workflow_execution():
|
|||
)
|
||||
|
||||
# raise_if_closed attribute
|
||||
domain.get_workflow_execution("wf-id-1", run_id="run-id-1", raise_if_closed=True).should.equal(wfe1)
|
||||
domain.get_workflow_execution(
|
||||
"wf-id-1", run_id="run-id-1", raise_if_closed=True).should.equal(wfe1)
|
||||
domain.get_workflow_execution.when.called_with(
|
||||
"wf-id-3", run_id="run-id-4", raise_if_closed=True
|
||||
).should.throw(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from moto.swf.models import GenericType
|
|||
|
||||
# Tests for GenericType (ActivityType, WorkflowType)
|
||||
class FooType(GenericType):
|
||||
|
||||
@property
|
||||
def kind(self):
|
||||
return "foo"
|
||||
|
|
@ -38,10 +39,12 @@ def test_type_full_dict_representation():
|
|||
_type.to_full_dict()["configuration"].should.equal({})
|
||||
|
||||
_type.task_list = "foo"
|
||||
_type.to_full_dict()["configuration"]["defaultTaskList"].should.equal({"name": "foo"})
|
||||
_type.to_full_dict()["configuration"][
|
||||
"defaultTaskList"].should.equal({"name": "foo"})
|
||||
|
||||
_type.just_an_example_timeout = "60"
|
||||
_type.to_full_dict()["configuration"]["justAnExampleTimeout"].should.equal("60")
|
||||
_type.to_full_dict()["configuration"][
|
||||
"justAnExampleTimeout"].should.equal("60")
|
||||
|
||||
_type.non_whitelisted_property = "34"
|
||||
keys = _type.to_full_dict()["configuration"].keys()
|
||||
|
|
@ -50,4 +53,5 @@ def test_type_full_dict_representation():
|
|||
|
||||
def test_type_string_representation():
|
||||
_type = FooType("test-foo", "v1.0")
|
||||
str(_type).should.equal("FooType(name: test-foo, version: v1.0, status: REGISTERED)")
|
||||
str(_type).should.equal(
|
||||
"FooType(name: test-foo, version: v1.0, status: REGISTERED)")
|
||||
|
|
|
|||
|
|
@ -240,8 +240,10 @@ def test_workflow_execution_schedule_activity_task():
|
|||
wfe.open_counts["openActivityTasks"].should.equal(1)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ActivityTaskScheduled")
|
||||
last_event.event_attributes["decisionTaskCompletedEventId"].should.equal(123)
|
||||
last_event.event_attributes["taskList"]["name"].should.equal("task-list-name")
|
||||
last_event.event_attributes[
|
||||
"decisionTaskCompletedEventId"].should.equal(123)
|
||||
last_event.event_attributes["taskList"][
|
||||
"name"].should.equal("task-list-name")
|
||||
|
||||
wfe.activity_tasks.should.have.length_of(1)
|
||||
task = wfe.activity_tasks[0]
|
||||
|
|
@ -288,43 +290,50 @@ def test_workflow_execution_schedule_activity_task_should_fail_if_wrong_attribut
|
|||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("ACTIVITY_TYPE_DOES_NOT_EXIST")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"ACTIVITY_TYPE_DOES_NOT_EXIST")
|
||||
|
||||
hsh["activityType"]["name"] = "test-activity"
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("ACTIVITY_TYPE_DEPRECATED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"ACTIVITY_TYPE_DEPRECATED")
|
||||
|
||||
hsh["activityType"]["version"] = "v1.2"
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("DEFAULT_TASK_LIST_UNDEFINED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"DEFAULT_TASK_LIST_UNDEFINED")
|
||||
|
||||
hsh["taskList"] = {"name": "foobar"}
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED")
|
||||
|
||||
hsh["scheduleToStartTimeout"] = "600"
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED")
|
||||
|
||||
hsh["scheduleToCloseTimeout"] = "600"
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED")
|
||||
|
||||
hsh["startToCloseTimeout"] = "600"
|
||||
wfe.schedule_activity_task(123, hsh)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED")
|
||||
|
||||
wfe.open_counts["openActivityTasks"].should.equal(0)
|
||||
wfe.activity_tasks.should.have.length_of(0)
|
||||
|
|
@ -393,7 +402,8 @@ def test_workflow_execution_schedule_activity_task_with_same_activity_id():
|
|||
wfe.open_counts["openActivityTasks"].should.equal(1)
|
||||
last_event = wfe.events()[-1]
|
||||
last_event.event_type.should.equal("ScheduleActivityTaskFailed")
|
||||
last_event.event_attributes["cause"].should.equal("ACTIVITY_ID_ALREADY_IN_USE")
|
||||
last_event.event_attributes["cause"].should.equal(
|
||||
"ACTIVITY_ID_ALREADY_IN_USE")
|
||||
|
||||
|
||||
def test_workflow_execution_start_activity_task():
|
||||
|
|
@ -456,7 +466,8 @@ def test_first_timeout():
|
|||
wfe.first_timeout().should.be.a(Timeout)
|
||||
|
||||
|
||||
# See moto/swf/models/workflow_execution.py "_process_timeouts()" for more details
|
||||
# See moto/swf/models/workflow_execution.py "_process_timeouts()" for more
|
||||
# details
|
||||
def test_timeouts_are_processed_in_order_and_reevaluated():
|
||||
# Let's make a Workflow Execution with the following properties:
|
||||
# - execution start to close timeout of 8 mins
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue