parent
df84675ae6
commit
bf3fff6e2c
2 changed files with 23 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
|
import yaml
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import boto.cloudformation
|
import boto.cloudformation
|
||||||
|
|
@ -17,7 +18,7 @@ class FakeStack(BaseModel):
|
||||||
self.stack_id = stack_id
|
self.stack_id = stack_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.template = template
|
self.template = template
|
||||||
self.template_dict = json.loads(self.template)
|
self._parse_template()
|
||||||
self.parameters = parameters
|
self.parameters = parameters
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.notification_arns = notification_arns if notification_arns else []
|
self.notification_arns = notification_arns if notification_arns else []
|
||||||
|
|
@ -70,6 +71,12 @@ class FakeStack(BaseModel):
|
||||||
resource_properties=resource_properties,
|
resource_properties=resource_properties,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def _parse_template(self):
|
||||||
|
try:
|
||||||
|
self.template_dict = json.loads(self.template)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
self.template_dict = yaml.load(self.template)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stack_parameters(self):
|
def stack_parameters(self):
|
||||||
return self.resource_map.resolved_parameters
|
return self.resource_map.resolved_parameters
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import json
|
import json
|
||||||
|
import yaml
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
@ -126,6 +127,20 @@ def test_parse_stack_with_name_type_resource():
|
||||||
queue.should.be.a(Queue)
|
queue.should.be.a(Queue)
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_stack_with_yaml_template():
|
||||||
|
stack = FakeStack(
|
||||||
|
stack_id="test_id",
|
||||||
|
name="test_stack",
|
||||||
|
template=yaml.dump(name_type_template),
|
||||||
|
parameters={},
|
||||||
|
region_name='us-west-1')
|
||||||
|
|
||||||
|
stack.resource_map.should.have.length_of(1)
|
||||||
|
list(stack.resource_map.keys())[0].should.equal('Queue')
|
||||||
|
queue = list(stack.resource_map.values())[0]
|
||||||
|
queue.should.be.a(Queue)
|
||||||
|
|
||||||
|
|
||||||
def test_parse_stack_with_outputs():
|
def test_parse_stack_with_outputs():
|
||||||
stack = FakeStack(
|
stack = FakeStack(
|
||||||
stack_id="test_id",
|
stack_id="test_id",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue