moto/tests/test_opsworks/test_stack.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.3 KiB
Python
Raw Normal View History

2016-04-12 20:23:35 +00:00
import boto3
import pytest
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():
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",
DefaultInstanceProfileArn="profile_arn",
)
assert "StackId" in response
2016-04-12 20:23:35 +00:00
@mock_opsworks
def test_describe_stacks():
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(
Name=f"test_stack_{i}",
2016-04-12 20:23:35 +00:00
Region="us-east-1",
ServiceRoleArn="service_arn",
DefaultInstanceProfileArn="profile_arn",
)
response = client.describe_stacks()
assert len(response["Stacks"]) == 3
for stack in response["Stacks"]:
assert stack["ServiceRoleArn"] == "service_arn"
assert stack["DefaultInstanceProfileArn"] == "profile_arn"
2016-04-12 20:23:35 +00:00
_id = response["Stacks"][0]["StackId"]
response = client.describe_stacks(StackIds=[_id])
assert len(response["Stacks"]) == 1
assert _id in response["Stacks"][0]["Arn"]
2016-04-12 20:23:35 +00:00
# ClientError/ResourceNotFoundException
with pytest.raises(Exception) as exc:
client.describe_stacks(StackIds=["foo"])
assert r"foo" in exc.value.response["Error"]["Message"]