Skip to content

Commit

Permalink
Fix state to start as PENDING and only become SCHEDULED on activation.
Browse files Browse the repository at this point in the history
  • Loading branch information
spulec committed Sep 16, 2015
1 parent b0ea9f2 commit db23b7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 3 additions & 2 deletions moto/datapipeline/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ def __init__(self, name, unique_id):
self.pipeline_id = get_random_pipeline_id()
self.creation_time = datetime.datetime.utcnow()
self.objects = []
self.status = "PENDING"

def to_json(self):
return {
"Description": self.description,
"Fields": [{
"key": "@pipelineState",
"stringValue": "SCHEDULED"
"stringValue": self.status,
}, {
"key": "description",
"stringValue": self.description
Expand Down Expand Up @@ -76,7 +77,7 @@ def set_pipeline_objects(self, pipeline_objects):
]

def activate(self):
pass
self.status = "SCHEDULED"


class DataPipelineBackend(BaseBackend):
Expand Down
20 changes: 13 additions & 7 deletions tests/test_datapipeline/test_datapipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from moto import mock_datapipeline


def get_value_from_fields(key, fields):
for field in fields:
if field['key'] == key:
return field['stringValue']


@mock_datapipeline
def test_create_pipeline():
conn = boto.datapipeline.connect_to_region("us-west-2")
Expand All @@ -21,12 +27,7 @@ def test_create_pipeline():
pipeline_description["PipelineId"].should.equal(pipeline_id)
fields = pipeline_description['Fields']

def get_value_from_fields(key, fields):
for field in fields:
if field['key'] == key:
return field['stringValue']

get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")
get_value_from_fields('@pipelineState', fields).should.equal("PENDING")
get_value_from_fields('uniqueId', fields).should.equal("some-unique-id")


Expand Down Expand Up @@ -123,4 +124,9 @@ def test_activate_pipeline():
pipeline_id = res["pipelineId"]
conn.activate_pipeline(pipeline_id)

# TODO what do we need to assert here. Change in pipeline status?
pipeline_descriptions = conn.describe_pipelines([pipeline_id])["PipelineDescriptionList"]
pipeline_descriptions.should.have.length_of(1)
pipeline_description = pipeline_descriptions[0]
fields = pipeline_description['Fields']

get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")

0 comments on commit db23b7d

Please sign in to comment.