Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -16,7 +16,8 @@ from tests.helpers import requires_boto_gte
|
|||
@mock_elb_deprecated
|
||||
def test_create_autoscaling_group():
|
||||
elb_conn = boto.ec2.elb.connect_to_region('us-east-1')
|
||||
elb_conn.create_load_balancer('test_lb', zones=[], listeners=[(80, 8080, 'http')])
|
||||
elb_conn.create_load_balancer(
|
||||
'test_lb', zones=[], listeners=[(80, 8080, 'http')])
|
||||
|
||||
conn = boto.ec2.autoscale.connect_to_region('us-east-1')
|
||||
config = LaunchConfiguration(
|
||||
|
|
@ -45,14 +46,15 @@ def test_create_autoscaling_group():
|
|||
key='test_key',
|
||||
value='test_value',
|
||||
propagate_at_launch=True
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
conn.create_auto_scaling_group(group)
|
||||
|
||||
group = conn.get_all_groups()[0]
|
||||
group.name.should.equal('tester_group')
|
||||
set(group.availability_zones).should.equal(set(['us-east-1c', 'us-east-1b']))
|
||||
set(group.availability_zones).should.equal(
|
||||
set(['us-east-1c', 'us-east-1b']))
|
||||
group.desired_capacity.should.equal(2)
|
||||
group.max_size.should.equal(2)
|
||||
group.min_size.should.equal(2)
|
||||
|
|
@ -64,7 +66,8 @@ def test_create_autoscaling_group():
|
|||
group.health_check_type.should.equal("EC2")
|
||||
list(group.load_balancers).should.equal(["test_lb"])
|
||||
group.placement_group.should.equal("test_placement")
|
||||
list(group.termination_policies).should.equal(["OldestInstance", "NewestInstance"])
|
||||
list(group.termination_policies).should.equal(
|
||||
["OldestInstance", "NewestInstance"])
|
||||
len(list(group.tags)).should.equal(1)
|
||||
tag = list(group.tags)[0]
|
||||
tag.resource_id.should.equal('tester_group')
|
||||
|
|
@ -134,7 +137,8 @@ def test_autoscaling_group_describe_filter():
|
|||
group.name = 'tester_group3'
|
||||
conn.create_auto_scaling_group(group)
|
||||
|
||||
conn.get_all_groups(names=['tester_group', 'tester_group2']).should.have.length_of(2)
|
||||
conn.get_all_groups(
|
||||
names=['tester_group', 'tester_group2']).should.have.length_of(2)
|
||||
conn.get_all_groups().should.have.length_of(3)
|
||||
|
||||
|
||||
|
|
@ -197,16 +201,16 @@ def test_autoscaling_tags_update():
|
|||
conn.create_auto_scaling_group(group)
|
||||
|
||||
conn.create_or_update_tags(tags=[Tag(
|
||||
resource_id='tester_group',
|
||||
key='test_key',
|
||||
value='new_test_value',
|
||||
propagate_at_launch=True
|
||||
), Tag(
|
||||
resource_id='tester_group',
|
||||
key='test_key2',
|
||||
value='test_value2',
|
||||
propagate_at_launch=True
|
||||
)])
|
||||
resource_id='tester_group',
|
||||
key='test_key',
|
||||
value='new_test_value',
|
||||
propagate_at_launch=True
|
||||
), Tag(
|
||||
resource_id='tester_group',
|
||||
key='test_key2',
|
||||
value='test_value2',
|
||||
propagate_at_launch=True
|
||||
)])
|
||||
group = conn.get_all_groups()[0]
|
||||
group.tags.should.have.length_of(2)
|
||||
|
||||
|
|
@ -372,6 +376,7 @@ def test_set_desired_capacity_the_same():
|
|||
instances = list(conn.get_all_autoscaling_instances())
|
||||
instances.should.have.length_of(2)
|
||||
|
||||
|
||||
@mock_autoscaling_deprecated
|
||||
@mock_elb_deprecated
|
||||
def test_autoscaling_group_with_elb():
|
||||
|
|
@ -402,7 +407,8 @@ def test_autoscaling_group_with_elb():
|
|||
group.desired_capacity.should.equal(2)
|
||||
elb.instances.should.have.length_of(2)
|
||||
|
||||
autoscale_instance_ids = set(instance.instance_id for instance in group.instances)
|
||||
autoscale_instance_ids = set(
|
||||
instance.instance_id for instance in group.instances)
|
||||
elb_instace_ids = set(instance.id for instance in elb.instances)
|
||||
autoscale_instance_ids.should.equal(elb_instace_ids)
|
||||
|
||||
|
|
@ -412,7 +418,8 @@ def test_autoscaling_group_with_elb():
|
|||
group.desired_capacity.should.equal(3)
|
||||
elb.instances.should.have.length_of(3)
|
||||
|
||||
autoscale_instance_ids = set(instance.instance_id for instance in group.instances)
|
||||
autoscale_instance_ids = set(
|
||||
instance.instance_id for instance in group.instances)
|
||||
elb_instace_ids = set(instance.id for instance in elb.instances)
|
||||
autoscale_instance_ids.should.equal(elb_instace_ids)
|
||||
|
||||
|
|
@ -429,38 +436,39 @@ Boto3
|
|||
|
||||
@mock_autoscaling
|
||||
def test_create_autoscaling_group_boto3():
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
_ = client.create_launch_configuration(
|
||||
LaunchConfigurationName='test_launch_configuration'
|
||||
)
|
||||
response = client.create_auto_scaling_group(
|
||||
AutoScalingGroupName='test_asg',
|
||||
LaunchConfigurationName='test_launch_configuration',
|
||||
MinSize=0,
|
||||
MaxSize=20,
|
||||
DesiredCapacity=5
|
||||
)
|
||||
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
_ = client.create_launch_configuration(
|
||||
LaunchConfigurationName='test_launch_configuration'
|
||||
)
|
||||
response = client.create_auto_scaling_group(
|
||||
AutoScalingGroupName='test_asg',
|
||||
LaunchConfigurationName='test_launch_configuration',
|
||||
MinSize=0,
|
||||
MaxSize=20,
|
||||
DesiredCapacity=5
|
||||
)
|
||||
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
||||
|
||||
|
||||
@mock_autoscaling
|
||||
def test_describe_autoscaling_groups_boto3():
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
_ = client.create_launch_configuration(
|
||||
LaunchConfigurationName='test_launch_configuration'
|
||||
)
|
||||
_ = client.create_auto_scaling_group(
|
||||
AutoScalingGroupName='test_asg',
|
||||
LaunchConfigurationName='test_launch_configuration',
|
||||
MinSize=0,
|
||||
MaxSize=20,
|
||||
DesiredCapacity=5
|
||||
)
|
||||
response = client.describe_auto_scaling_groups(
|
||||
AutoScalingGroupNames=["test_asg"]
|
||||
)
|
||||
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
||||
response['AutoScalingGroups'][0]['AutoScalingGroupName'].should.equal('test_asg')
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
_ = client.create_launch_configuration(
|
||||
LaunchConfigurationName='test_launch_configuration'
|
||||
)
|
||||
_ = client.create_auto_scaling_group(
|
||||
AutoScalingGroupName='test_asg',
|
||||
LaunchConfigurationName='test_launch_configuration',
|
||||
MinSize=0,
|
||||
MaxSize=20,
|
||||
DesiredCapacity=5
|
||||
)
|
||||
response = client.describe_auto_scaling_groups(
|
||||
AutoScalingGroupNames=["test_asg"]
|
||||
)
|
||||
response['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
||||
response['AutoScalingGroups'][0][
|
||||
'AutoScalingGroupName'].should.equal('test_asg')
|
||||
|
||||
|
||||
@mock_autoscaling
|
||||
|
|
@ -509,22 +517,23 @@ def test_autoscaling_taqs_update_boto3():
|
|||
)
|
||||
|
||||
client.create_or_update_tags(Tags=[{
|
||||
"ResourceId": 'test_asg',
|
||||
"Key": 'test_key',
|
||||
"Value": 'updated_test_value',
|
||||
"PropagateAtLaunch": True
|
||||
}, {
|
||||
"ResourceId": 'test_asg',
|
||||
"Key": 'test_key2',
|
||||
"Value": 'test_value2',
|
||||
"PropagateAtLaunch": True
|
||||
}])
|
||||
"ResourceId": 'test_asg',
|
||||
"Key": 'test_key',
|
||||
"Value": 'updated_test_value',
|
||||
"PropagateAtLaunch": True
|
||||
}, {
|
||||
"ResourceId": 'test_asg',
|
||||
"Key": 'test_key2',
|
||||
"Value": 'test_value2',
|
||||
"PropagateAtLaunch": True
|
||||
}])
|
||||
|
||||
response = client.describe_auto_scaling_groups(
|
||||
AutoScalingGroupNames=["test_asg"]
|
||||
)
|
||||
response['AutoScalingGroups'][0]['Tags'].should.have.length_of(2)
|
||||
|
||||
|
||||
@mock_autoscaling
|
||||
def test_autoscaling_describe_policies_boto3():
|
||||
client = boto3.client('autoscaling', region_name='us-east-1')
|
||||
|
|
@ -577,4 +586,5 @@ def test_autoscaling_describe_policies_boto3():
|
|||
PolicyTypes=['SimpleScaling']
|
||||
)
|
||||
response['ScalingPolicies'].should.have.length_of(1)
|
||||
response['ScalingPolicies'][0]['PolicyName'].should.equal('test_policy_down')
|
||||
response['ScalingPolicies'][0][
|
||||
'PolicyName'].should.equal('test_policy_down')
|
||||
|
|
|
|||
|
|
@ -30,10 +30,12 @@ def test_create_launch_configuration():
|
|||
launch_config.image_id.should.equal('ami-abcd1234')
|
||||
launch_config.instance_type.should.equal('t1.micro')
|
||||
launch_config.key_name.should.equal('the_keys')
|
||||
set(launch_config.security_groups).should.equal(set(['default', 'default2']))
|
||||
set(launch_config.security_groups).should.equal(
|
||||
set(['default', 'default2']))
|
||||
launch_config.user_data.should.equal(b"This is some user_data")
|
||||
launch_config.instance_monitoring.enabled.should.equal('true')
|
||||
launch_config.instance_profile_name.should.equal('arn:aws:iam::123456789012:instance-profile/testing')
|
||||
launch_config.instance_profile_name.should.equal(
|
||||
'arn:aws:iam::123456789012:instance-profile/testing')
|
||||
launch_config.spot_price.should.equal(0.1)
|
||||
|
||||
|
||||
|
|
@ -78,16 +80,19 @@ def test_create_launch_configuration_with_block_device_mappings():
|
|||
launch_config.image_id.should.equal('ami-abcd1234')
|
||||
launch_config.instance_type.should.equal('m1.small')
|
||||
launch_config.key_name.should.equal('the_keys')
|
||||
set(launch_config.security_groups).should.equal(set(['default', 'default2']))
|
||||
set(launch_config.security_groups).should.equal(
|
||||
set(['default', 'default2']))
|
||||
launch_config.user_data.should.equal(b"This is some user_data")
|
||||
launch_config.instance_monitoring.enabled.should.equal('true')
|
||||
launch_config.instance_profile_name.should.equal('arn:aws:iam::123456789012:instance-profile/testing')
|
||||
launch_config.instance_profile_name.should.equal(
|
||||
'arn:aws:iam::123456789012:instance-profile/testing')
|
||||
launch_config.spot_price.should.equal(0.1)
|
||||
len(launch_config.block_device_mappings).should.equal(3)
|
||||
|
||||
returned_mapping = launch_config.block_device_mappings
|
||||
|
||||
set(returned_mapping.keys()).should.equal(set(['/dev/xvdb', '/dev/xvdp', '/dev/xvdh']))
|
||||
set(returned_mapping.keys()).should.equal(
|
||||
set(['/dev/xvdb', '/dev/xvdp', '/dev/xvdh']))
|
||||
|
||||
returned_mapping['/dev/xvdh'].iops.should.equal(1000)
|
||||
returned_mapping['/dev/xvdh'].size.should.equal(100)
|
||||
|
|
@ -198,7 +203,8 @@ def test_launch_configuration_describe_filter():
|
|||
config.name = 'tester3'
|
||||
conn.create_launch_configuration(config)
|
||||
|
||||
conn.get_all_launch_configurations(names=['tester', 'tester2']).should.have.length_of(2)
|
||||
conn.get_all_launch_configurations(
|
||||
names=['tester', 'tester2']).should.have.length_of(2)
|
||||
conn.get_all_launch_configurations().should.have.length_of(3)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue