moto/tests/test_opsworks/test_stack.py

46 lines
1.4 KiB
Python
Raw Normal View History

2016-04-12 20:23:35 +00:00
import boto3
2021-10-18 19:44:29 +00:00
import sure # noqa # pylint: disable=unused-import
import re
2016-04-12 20:23:35 +00:00
from moto import mock_opsworks
2016-04-12 20:23:35 +00:00
@mock_opsworks
def test_create_stack_response():
2019-10-31 15:44:26 +00:00
client = boto3.client("opsworks", region_name="us-east-1")
2016-04-12 20:23:35 +00:00
response = client.create_stack(
Name="test_stack_1",
Region="us-east-1",
ServiceRoleArn="service_arn",
2019-10-31 15:44:26 +00:00
DefaultInstanceProfileArn="profile_arn",
2016-04-12 20:23:35 +00:00
)
response.should.contain("StackId")
@mock_opsworks
def test_describe_stacks():
2019-10-31 15:44:26 +00:00
client = boto3.client("opsworks", region_name="us-east-1")
for i in range(1, 4):
2016-04-12 20:23:35 +00:00
client.create_stack(
2016-04-18 20:36:30 +00:00
Name="test_stack_{0}".format(i),
2016-04-12 20:23:35 +00:00
Region="us-east-1",
ServiceRoleArn="service_arn",
2019-10-31 15:44:26 +00:00
DefaultInstanceProfileArn="profile_arn",
2016-04-12 20:23:35 +00:00
)
response = client.describe_stacks()
2019-10-31 15:44:26 +00:00
response["Stacks"].should.have.length_of(3)
for stack in response["Stacks"]:
stack["ServiceRoleArn"].should.equal("service_arn")
stack["DefaultInstanceProfileArn"].should.equal("profile_arn")
2016-04-12 20:23:35 +00:00
2019-10-31 15:44:26 +00:00
_id = response["Stacks"][0]["StackId"]
2016-04-12 20:23:35 +00:00
response = client.describe_stacks(StackIds=[_id])
2019-10-31 15:44:26 +00:00
response["Stacks"].should.have.length_of(1)
response["Stacks"][0]["Arn"].should.contain(_id)
2016-04-12 20:23:35 +00:00
# ClientError/ResourceNotFoundException
client.describe_stacks.when.called_with(StackIds=["foo"]).should.throw(
2019-10-31 15:44:26 +00:00
Exception, re.compile(r"foo")
)