Add basic ActivityTask model
This commit is contained in:
parent
49e44c8ee6
commit
fa4608be98
@ -13,6 +13,7 @@ from ..exceptions import (
|
|||||||
SWFTypeDeprecatedFault,
|
SWFTypeDeprecatedFault,
|
||||||
SWFValidationException,
|
SWFValidationException,
|
||||||
)
|
)
|
||||||
|
from .activity_task import ActivityTask
|
||||||
from .activity_type import ActivityType
|
from .activity_type import ActivityType
|
||||||
from .decision_task import DecisionTask
|
from .decision_task import DecisionTask
|
||||||
from .domain import Domain
|
from .domain import Domain
|
||||||
|
20
moto/swf/models/activity_task.py
Normal file
20
moto/swf/models/activity_task.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class ActivityTask(object):
|
||||||
|
def __init__(self, activity_id, activity_type, workflow_execution, input=None):
|
||||||
|
self.activity_id = activity_id
|
||||||
|
self.activity_type = activity_type
|
||||||
|
self.input = input
|
||||||
|
self.started_event_id = None
|
||||||
|
self.state = "SCHEDULED"
|
||||||
|
self.task_token = str(uuid.uuid4())
|
||||||
|
self.workflow_execution = workflow_execution
|
||||||
|
|
||||||
|
def start(self, started_event_id):
|
||||||
|
self.state = "STARTED"
|
||||||
|
self.started_event_id = started_event_id
|
||||||
|
|
||||||
|
def complete(self):
|
||||||
|
self.state = "COMPLETED"
|
@ -2,6 +2,7 @@ from sure import expect
|
|||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from moto.swf.models import (
|
from moto.swf.models import (
|
||||||
|
ActivityTask,
|
||||||
DecisionTask,
|
DecisionTask,
|
||||||
Domain,
|
Domain,
|
||||||
GenericType,
|
GenericType,
|
||||||
@ -301,3 +302,26 @@ def test_decision_task_full_dict_representation():
|
|||||||
dt.start(1234)
|
dt.start(1234)
|
||||||
fd = dt.to_full_dict()
|
fd = dt.to_full_dict()
|
||||||
fd["startedEventId"].should.equal(1234)
|
fd["startedEventId"].should.equal(1234)
|
||||||
|
|
||||||
|
|
||||||
|
# ActivityTask
|
||||||
|
def test_activity_task_creation():
|
||||||
|
wft = get_basic_workflow_type()
|
||||||
|
wfe = WorkflowExecution(wft, "ab1234")
|
||||||
|
task = ActivityTask(
|
||||||
|
activity_id="my-activity-123",
|
||||||
|
activity_type="foo",
|
||||||
|
input="optional",
|
||||||
|
workflow_execution=wfe,
|
||||||
|
)
|
||||||
|
task.workflow_execution.should.equal(wfe)
|
||||||
|
task.state.should.equal("SCHEDULED")
|
||||||
|
task.task_token.should_not.be.empty
|
||||||
|
task.started_event_id.should.be.none
|
||||||
|
|
||||||
|
task.start(123)
|
||||||
|
task.state.should.equal("STARTED")
|
||||||
|
task.started_event_id.should.equal(123)
|
||||||
|
|
||||||
|
task.complete()
|
||||||
|
task.state.should.equal("COMPLETED")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user