From f46a24180f9a2a84b61b05efdb57126cffaca113 Mon Sep 17 00:00:00 2001 From: William Richard Date: Sat, 4 Mar 2017 22:51:01 -0500 Subject: [PATCH] Cast desired capacity for cloudformation asg to int (#846) Cloudformation passes MaxSize, MinSize and DesiredCapacity as strings, but we want to store them as ints. Also includes tests of this fix, to help avoid regression. --- moto/autoscaling/models.py | 1 + .../test_cloudformation_stack_integration.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/moto/autoscaling/models.py b/moto/autoscaling/models.py index 53a0f62df..2b5a07c15 100644 --- a/moto/autoscaling/models.py +++ b/moto/autoscaling/models.py @@ -324,6 +324,7 @@ class AutoScalingBackend(BaseBackend): max_size = make_int(max_size) min_size = make_int(min_size) + desired_capacity = make_int(desired_capacity) default_cooldown = make_int(default_cooldown) if health_check_period is None: health_check_period = 300 diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py index c168ff723..f842ffe70 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_integration.py +++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py @@ -535,6 +535,7 @@ def test_autoscaling_group_with_elb(): "LaunchConfigurationName": {"Ref": "my-launch-config"}, "MinSize": "2", "MaxSize": "2", + "DesiredCapacity": "2", "LoadBalancerNames": [{"Ref": "my-elb"}] }, }, @@ -614,6 +615,7 @@ def test_autoscaling_group_update(): "LaunchConfigurationName": {"Ref": "my-launch-config"}, "MinSize": "2", "MaxSize": "2", + "DesiredCapacity": "2" }, }, @@ -638,6 +640,7 @@ def test_autoscaling_group_update(): asg = autoscale_conn.get_all_groups()[0] asg.min_size.should.equal(2) asg.max_size.should.equal(2) + asg.desired_capacity.should.equal(2) asg_template['Resources']['my-as-group']['Properties']['MaxSize'] = 3 asg_template_json = json.dumps(asg_template) @@ -648,6 +651,7 @@ def test_autoscaling_group_update(): asg = autoscale_conn.get_all_groups()[0] asg.min_size.should.equal(2) asg.max_size.should.equal(3) + asg.desired_capacity.should.equal(2) @mock_ec2()