From 8ce2d3c8bf148b3f86a8a7eff4495b70897f0346 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Wed, 4 May 2016 22:10:11 -0400 Subject: [PATCH] Cleanup updating ASGs. Closes #603. --- moto/autoscaling/models.py | 21 ++++++++++++++------- tests/test_autoscaling/test_autoscaling.py | 6 +++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/moto/autoscaling/models.py b/moto/autoscaling/models.py index bf4c42fd7..e4c6f1081 100644 --- a/moto/autoscaling/models.py +++ b/moto/autoscaling/models.py @@ -217,18 +217,25 @@ class FakeAutoScalingGroup(object): launch_config_name, vpc_zone_identifier, default_cooldown, health_check_period, health_check_type, load_balancers, placement_group, termination_policies): - self.availability_zones = availability_zones - self.max_size = max_size - self.min_size = min_size + if availability_zones: + self.availability_zones = availability_zones + if max_size is not None: + self.max_size = max_size + if min_size is not None: + self.min_size = min_size if launch_config_name: self.launch_config = self.autoscaling_backend.launch_configurations[launch_config_name] self.launch_config_name = launch_config_name - self.vpc_zone_identifier = vpc_zone_identifier - self.health_check_period = health_check_period - self.health_check_type = health_check_type + if vpc_zone_identifier is not None: + self.vpc_zone_identifier = vpc_zone_identifier + if health_check_period is not None: + self.health_check_period = health_check_period + if health_check_type is not None: + self.health_check_type = health_check_type - self.set_desired_capacity(desired_capacity) + if desired_capacity is not None: + self.set_desired_capacity(desired_capacity) def set_desired_capacity(self, new_capacity): if new_capacity is None: diff --git a/tests/test_autoscaling/test_autoscaling.py b/tests/test_autoscaling/test_autoscaling.py index 7ee9b30f0..e48750700 100644 --- a/tests/test_autoscaling/test_autoscaling.py +++ b/tests/test_autoscaling/test_autoscaling.py @@ -437,5 +437,9 @@ def test_update_autoscaling_group_boto3(): response = client.update_auto_scaling_group( AutoScalingGroupName='test_asg', MinSize=1, - DesiredCapacity=1, ) + + response = client.describe_auto_scaling_groups( + AutoScalingGroupNames=["test_asg"] + ) + response['AutoScalingGroups'][0]['MinSize'].should.equal(1)