diff --git a/moto/swf/models/__init__.py b/moto/swf/models/__init__.py index c91da492e..3265d73da 100644 --- a/moto/swf/models/__init__.py +++ b/moto/swf/models/__init__.py @@ -13,6 +13,7 @@ from ..exceptions import ( SWFTypeDeprecatedFault, SWFValidationException, ) +from .activity_task import ActivityTask from .activity_type import ActivityType from .decision_task import DecisionTask from .domain import Domain diff --git a/moto/swf/models/activity_task.py b/moto/swf/models/activity_task.py new file mode 100644 index 000000000..298984a21 --- /dev/null +++ b/moto/swf/models/activity_task.py @@ -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" diff --git a/tests/test_swf/test_models.py b/tests/test_swf/test_models.py index 5af593821..4707140e0 100644 --- a/tests/test_swf/test_models.py +++ b/tests/test_swf/test_models.py @@ -2,6 +2,7 @@ from sure import expect from freezegun import freeze_time from moto.swf.models import ( + ActivityTask, DecisionTask, Domain, GenericType, @@ -301,3 +302,26 @@ def test_decision_task_full_dict_representation(): dt.start(1234) fd = dt.to_full_dict() 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")