Fix state to start as PENDING and only become SCHEDULED on activation.
This commit is contained in:
parent
b0ea9f2859
commit
db23b7d24c
@ -28,13 +28,14 @@ class Pipeline(object):
|
|||||||
self.pipeline_id = get_random_pipeline_id()
|
self.pipeline_id = get_random_pipeline_id()
|
||||||
self.creation_time = datetime.datetime.utcnow()
|
self.creation_time = datetime.datetime.utcnow()
|
||||||
self.objects = []
|
self.objects = []
|
||||||
|
self.status = "PENDING"
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return {
|
return {
|
||||||
"Description": self.description,
|
"Description": self.description,
|
||||||
"Fields": [{
|
"Fields": [{
|
||||||
"key": "@pipelineState",
|
"key": "@pipelineState",
|
||||||
"stringValue": "SCHEDULED"
|
"stringValue": self.status,
|
||||||
}, {
|
}, {
|
||||||
"key": "description",
|
"key": "description",
|
||||||
"stringValue": self.description
|
"stringValue": self.description
|
||||||
@ -76,7 +77,7 @@ class Pipeline(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
pass
|
self.status = "SCHEDULED"
|
||||||
|
|
||||||
|
|
||||||
class DataPipelineBackend(BaseBackend):
|
class DataPipelineBackend(BaseBackend):
|
||||||
|
@ -6,6 +6,12 @@ import sure # noqa
|
|||||||
from moto import mock_datapipeline
|
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
|
@mock_datapipeline
|
||||||
def test_create_pipeline():
|
def test_create_pipeline():
|
||||||
conn = boto.datapipeline.connect_to_region("us-west-2")
|
conn = boto.datapipeline.connect_to_region("us-west-2")
|
||||||
@ -21,12 +27,7 @@ def test_create_pipeline():
|
|||||||
pipeline_description["PipelineId"].should.equal(pipeline_id)
|
pipeline_description["PipelineId"].should.equal(pipeline_id)
|
||||||
fields = pipeline_description['Fields']
|
fields = pipeline_description['Fields']
|
||||||
|
|
||||||
def get_value_from_fields(key, fields):
|
get_value_from_fields('@pipelineState', fields).should.equal("PENDING")
|
||||||
for field in fields:
|
|
||||||
if field['key'] == key:
|
|
||||||
return field['stringValue']
|
|
||||||
|
|
||||||
get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")
|
|
||||||
get_value_from_fields('uniqueId', fields).should.equal("some-unique-id")
|
get_value_from_fields('uniqueId', fields).should.equal("some-unique-id")
|
||||||
|
|
||||||
|
|
||||||
@ -123,4 +124,9 @@ def test_activate_pipeline():
|
|||||||
pipeline_id = res["pipelineId"]
|
pipeline_id = res["pipelineId"]
|
||||||
conn.activate_pipeline(pipeline_id)
|
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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user