Merge pull request #1969 from grahamlyons/list-deleted-cloudformation-stacks

Return the deleted stacks in the list stacks call
This commit is contained in:
Steve Pulec 2018-12-28 21:07:06 -05:00 committed by GitHub
commit 5d172d9c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 7 deletions

View File

@ -224,7 +224,11 @@ class CloudFormationBackend(BaseBackend):
return list(stacks)
def list_stacks(self):
return self.stacks.values()
return [
v for v in self.stacks.values()
] + [
v for v in self.deleted_stacks.values()
]
def get_stack(self, name_or_stack_id):
all_stacks = dict(self.deleted_stacks, **self.stacks)

View File

@ -266,9 +266,9 @@ def test_delete_stack_by_name():
template_body=dummy_template_json,
)
conn.list_stacks().should.have.length_of(1)
conn.describe_stacks().should.have.length_of(1)
conn.delete_stack("test_stack")
conn.list_stacks().should.have.length_of(0)
conn.describe_stacks().should.have.length_of(0)
@mock_cloudformation_deprecated
@ -279,9 +279,9 @@ def test_delete_stack_by_id():
template_body=dummy_template_json,
)
conn.list_stacks().should.have.length_of(1)
conn.describe_stacks().should.have.length_of(1)
conn.delete_stack(stack_id)
conn.list_stacks().should.have.length_of(0)
conn.describe_stacks().should.have.length_of(0)
with assert_raises(BotoServerError):
conn.describe_stacks("test_stack")
@ -296,9 +296,9 @@ def test_delete_stack_with_resource_missing_delete_attr():
template_body=dummy_template_json3,
)
conn.list_stacks().should.have.length_of(1)
conn.describe_stacks().should.have.length_of(1)
conn.delete_stack("test_stack")
conn.list_stacks().should.have.length_of(0)
conn.describe_stacks().should.have.length_of(0)
@mock_cloudformation_deprecated

View File

@ -535,6 +535,21 @@ def test_delete_stack_by_name():
cf_conn.describe_stacks()['Stacks'].should.have.length_of(0)
@mock_cloudformation
def test_delete_stack():
cf = boto3.client('cloudformation', region_name='us-east-1')
cf.create_stack(
StackName="test_stack",
TemplateBody=dummy_template_json,
)
cf.delete_stack(
StackName="test_stack",
)
stacks = cf.list_stacks()
assert stacks['StackSummaries'][0]['StackStatus'] == 'DELETE_COMPLETE'
@mock_cloudformation
def test_describe_deleted_stack():
cf_conn = boto3.client('cloudformation', region_name='us-east-1')