Ensure activity and decision tasks cannot progress on a closed workflow

This is a second barrier because I'm a little nervous about this and I
don't want moto/swf to make any activity progress while in the real
world service, it's strictly impossible once the execution is closed.
Python doesn't seem to have any nice way of freezing an object so here
we go with a manual boundary...
This commit is contained in:
Jean-Baptiste Barth 2015-11-05 01:12:51 +01:00
commit 61bb550052
5 changed files with 60 additions and 4 deletions

View file

@ -1,6 +1,7 @@
from freezegun import freeze_time
from sure import expect
from moto.swf.exceptions import SWFWorkflowExecutionClosedError
from moto.swf.models import (
ActivityTask,
ActivityType,
@ -123,3 +124,21 @@ def test_activity_task_cannot_timeout_on_closed_workflow_execution():
wfe.has_timedout().should.equal(True)
wfe.process_timeouts()
task.has_timedout().should.equal(False)
def test_activity_task_cannot_change_state_on_closed_workflow_execution():
wfe = make_workflow_execution()
wfe.start()
task = ActivityTask(
activity_id="my-activity-123",
activity_type="foo",
input="optional",
scheduled_event_id=117,
timeouts=ACTIVITY_TASK_TIMEOUTS,
workflow_execution=wfe,
)
wfe.complete(123)
task.timeout.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
task.complete.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
task.fail.when.called_with().should.throw(SWFWorkflowExecutionClosedError)

View file

@ -1,6 +1,7 @@
from freezegun import freeze_time
from sure import expect
from moto.swf.exceptions import SWFWorkflowExecutionClosedError
from moto.swf.models import DecisionTask
from ..utils import make_workflow_execution
@ -61,3 +62,13 @@ def test_decision_task_cannot_timeout_on_closed_workflow_execution():
wfe.has_timedout().should.equal(True)
wfe.process_timeouts()
dt.has_timedout().should.equal(False)
def test_decision_task_cannot_change_state_on_closed_workflow_execution():
wfe = make_workflow_execution()
wfe.start()
task = DecisionTask(wfe, 123)
wfe.complete(123)
task.timeout.when.called_with().should.throw(SWFWorkflowExecutionClosedError)
task.complete.when.called_with().should.throw(SWFWorkflowExecutionClosedError)