From c308ef4364aa935afe9c50474f54fc8e59922cac Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 1 May 2016 22:34:16 -0400 Subject: [PATCH] Fix update_auto_scaling_group. Closes #596. --- moto/autoscaling/models.py | 5 +++-- tests/test_autoscaling/test_autoscaling.py | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/moto/autoscaling/models.py b/moto/autoscaling/models.py index eef22b397..bf4c42fd7 100644 --- a/moto/autoscaling/models.py +++ b/moto/autoscaling/models.py @@ -221,8 +221,9 @@ class FakeAutoScalingGroup(object): self.max_size = max_size self.min_size = min_size - self.launch_config = self.autoscaling_backend.launch_configurations[launch_config_name] - self.launch_config_name = launch_config_name + 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 diff --git a/tests/test_autoscaling/test_autoscaling.py b/tests/test_autoscaling/test_autoscaling.py index 6a5f768bf..7ee9b30f0 100644 --- a/tests/test_autoscaling/test_autoscaling.py +++ b/tests/test_autoscaling/test_autoscaling.py @@ -418,4 +418,24 @@ def test_describe_autoscaling_groups(): AutoScalingGroupNames=["test_asg"] ) response['ResponseMetadata']['HTTPStatusCode'].should.equal(200) - response['AutoScalingGroups'][0]['AutoScalingGroupName'].should.equal('test_asg') \ No newline at end of file + response['AutoScalingGroups'][0]['AutoScalingGroupName'].should.equal('test_asg') + +@mock_autoscaling +def test_update_autoscaling_group_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.update_auto_scaling_group( + AutoScalingGroupName='test_asg', + MinSize=1, + DesiredCapacity=1, + )