116 lines
2.7 KiB
Python
116 lines
2.7 KiB
Python
import json
|
|
|
|
import boto
|
|
import sure # noqa
|
|
|
|
from moto import mock_cloudformation
|
|
|
|
dummy_template = {
|
|
"AWSTemplateFormatVersion": "2010-09-09",
|
|
"Description": "Stack 1",
|
|
"Resources": {},
|
|
}
|
|
|
|
dummy_template2 = {
|
|
"AWSTemplateFormatVersion": "2010-09-09",
|
|
"Description": "Stack 2",
|
|
"Resources": {},
|
|
}
|
|
|
|
dummy_template_json = json.dumps(dummy_template)
|
|
dummy_template_json2 = json.dumps(dummy_template2)
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_create_stack():
|
|
conn = boto.connect_cloudformation()
|
|
conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
stack = conn.describe_stacks()[0]
|
|
stack.stack_name.should.equal('test_stack')
|
|
stack.get_template().should.equal(dummy_template)
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_describe_stack_by_name():
|
|
conn = boto.connect_cloudformation()
|
|
conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
stack = conn.describe_stacks("test_stack")[0]
|
|
stack.stack_name.should.equal('test_stack')
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_get_template_by_name():
|
|
conn = boto.connect_cloudformation()
|
|
conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
template = conn.get_template("test_stack")
|
|
template.should.equal(dummy_template)
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_list_stacks():
|
|
conn = boto.connect_cloudformation()
|
|
conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
conn.create_stack(
|
|
"test_stack2",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
stacks = conn.list_stacks()
|
|
stacks.should.have.length_of(2)
|
|
stacks[0].template_description.should.equal("Stack 1")
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_delete_stack_by_name():
|
|
conn = boto.connect_cloudformation()
|
|
conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
conn.list_stacks().should.have.length_of(1)
|
|
conn.delete_stack("test_stack")
|
|
conn.list_stacks().should.have.length_of(0)
|
|
|
|
|
|
@mock_cloudformation
|
|
def test_delete_stack_by_id():
|
|
conn = boto.connect_cloudformation()
|
|
stack_id = conn.create_stack(
|
|
"test_stack",
|
|
template_body=dummy_template_json,
|
|
)
|
|
|
|
conn.list_stacks().should.have.length_of(1)
|
|
conn.delete_stack(stack_id)
|
|
conn.list_stacks().should.have.length_of(0)
|
|
|
|
|
|
# @mock_cloudformation
|
|
# def test_update_stack():
|
|
# conn = boto.connect_cloudformation()
|
|
# conn.create_stack(
|
|
# "test_stack",
|
|
# template_body=dummy_template_json,
|
|
# )
|
|
|
|
# conn.update_stack("test_stack", dummy_template_json2)
|
|
|
|
# stack = conn.describe_stacks()[0]
|
|
# stack.get_template().should.equal(dummy_template2)
|