parent
df84675ae6
commit
bf3fff6e2c
@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
from datetime import datetime
|
||||
import json
|
||||
import yaml
|
||||
import uuid
|
||||
|
||||
import boto.cloudformation
|
||||
@ -17,7 +18,7 @@ class FakeStack(BaseModel):
|
||||
self.stack_id = stack_id
|
||||
self.name = name
|
||||
self.template = template
|
||||
self.template_dict = json.loads(self.template)
|
||||
self._parse_template()
|
||||
self.parameters = parameters
|
||||
self.region_name = region_name
|
||||
self.notification_arns = notification_arns if notification_arns else []
|
||||
@ -70,6 +71,12 @@ class FakeStack(BaseModel):
|
||||
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
|
||||
def stack_parameters(self):
|
||||
return self.resource_map.resolved_parameters
|
||||
|
@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from mock import patch
|
||||
import sure # noqa
|
||||
@ -126,6 +127,20 @@ def test_parse_stack_with_name_type_resource():
|
||||
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():
|
||||
stack = FakeStack(
|
||||
stack_id="test_id",
|
||||
|
Loading…
Reference in New Issue
Block a user