opsworks: impl create_layers; describe_layers

This commit is contained in:
Vladimir Sudilovsky 2016-04-14 16:28:53 -04:00
commit 2fe5b77861
5 changed files with 266 additions and 18 deletions

View file

@ -0,0 +1,69 @@
from __future__ import unicode_literals
import boto3
import sure # noqa
import re
from moto import mock_opsworks
@mock_opsworks
def test_create_layer_response():
client = boto3.client('opsworks')
stack_id = client.create_stack(
Name="test_stack_1",
Region="us-east-1",
ServiceRoleArn="service_arn",
DefaultInstanceProfileArn="profile_arn"
)['StackId']
response = client.create_layer(
StackId=stack_id,
Type="custom",
Name="TestLayer",
Shortname="TestLayerShortName"
)
response.should.contain("LayerId")
# ClientError
client.create_layer.when.called_with(
StackId=stack_id,
Type="custom",
Name="TestLayer",
Shortname="_"
).should.throw(
Exception, re.compile(r'already a layer named "TestLayer"')
)
# ClientError
client.create_layer.when.called_with(
StackId=stack_id,
Type="custom",
Name="_",
Shortname="TestLayerShortName"
).should.throw(
Exception, re.compile(r'already a layer with shortname "TestLayerShortName"')
)
@mock_opsworks
def test_describe_layers():
client = boto3.client('opsworks')
stack_id = client.create_stack(
Name="test_stack_1",
Region="us-east-1",
ServiceRoleArn="service_arn",
DefaultInstanceProfileArn="profile_arn"
)['StackId']
layer_id = client.create_layer(
StackId=stack_id,
Type="custom",
Name="TestLayer",
Shortname="TestLayerShortName"
)['LayerId']
rv1 = client.describe_layers(StackId=stack_id)
rv2 = client.describe_layers(LayerIds=[layer_id])
rv1.should.equal(rv2)
rv1['Layers'][0]['Name'].should.equal("TestLayer")

View file

@ -1,8 +1,9 @@
from __future__ import unicode_literals
import boto3
import sure # noqa
import re
from moto import mock_opsworks, mock_ec2, mock_elb
from moto import mock_opsworks
@mock_opsworks
@ -30,12 +31,18 @@ def test_describe_stacks():
response = client.describe_stacks()
response['Stacks'].should.have.length_of(3)
response['Stacks'][0]['ServiceRoleArn'].should.equal("service_arn")
response['Stacks'][0]['DefaultInstanceProfileArn'].should.equal("profile_arn")
for stack in response['Stacks']:
stack['ServiceRoleArn'].should.equal("service_arn")
stack['DefaultInstanceProfileArn'].should.equal("profile_arn")
_id = response['Stacks'][0]['StackId']
response = client.describe_stacks(StackIds=[_id])
response['Stacks'].should.have.length_of(1)
response['Stacks'][0]['Arn'].should.contain(_id)
# ClientError/ResourceNotFoundException
client.describe_stacks.when.called_with(StackIds=["foo"]).should.throw(
Exception, re.compile(r'foo')
)