# Path: stacker_blueprints/asg.py
# class FlexibleAutoScalingGroup(Blueprint):
#     """ A more flexible AutoscalingGroup Blueprint.
# 
#     Uses TroposphereTypes to make creating AutoscalingGroups and their
#     associated LaunchConfiguration more flexible. This comes at the price of
#     doing less for you.
#     """
#     VARIABLES = {
#         "LaunchConfiguration": {
#             "type": TroposphereType(autoscaling.LaunchConfiguration),
#             "description": "The LaunchConfiguration for the autoscaling "
#                            "group.",
#         },
#         "AutoScalingGroup": {
#             "type": TroposphereType(autoscaling.AutoScalingGroup),
#             "description": "The Autoscaling definition. Do not provide a "
#                            "LaunchConfiguration parameter, that will be "
#                            "automatically added from the LaunchConfiguration "
#                            "Variable.",
#         },
#     }
# 
#     def create_launch_configuration(self):
#         t = self.template
#         variables = self.get_variables()
#         self.launch_config = t.add_resource(variables["LaunchConfiguration"])
#         t.add_output(
#             Output("LaunchConfiguration", Value=self.launch_config.Ref())
#         )
# 
#     def add_launch_config_variable(self, asg):
#         if getattr(asg, "LaunchConfigurationName", False):
#             raise ValueError("Do not provide a LaunchConfigurationName "
#                              "variable for the AutoScalingGroup config.")
# 
#         asg.LaunchConfigurationName = self.launch_config.Ref()
#         return asg
# 
#     def create_autoscaling_group(self):
#         t = self.template
#         variables = self.get_variables()
#         asg = variables["AutoScalingGroup"]
#         asg = self.add_launch_config_variable(asg)
#         t.add_resource(asg)
#         t.add_output(Output("AutoScalingGroup", Value=asg.Ref()))
# 
#     def create_template(self):
#         self.create_launch_configuration()
#         self.create_autoscaling_group()


from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.asg import FlexibleAutoScalingGroup
from stacker.blueprints.testutil import BlueprintTestCase



class TestBlueprint(BlueprintTestCase):
    def setUp(self):
        self.launch_config = {
            "ImageId": "i-abc1234",
            "InstanceType": "m3.medium",
            "KeyName": "mock_ssh_key",
            "SecurityGroups": ["sg-abc1234", "sg-bcd2345"],
        }
        self.asg_config = {
            "MinSize": 1,
            "MaxSize": 3,
        }

        self.common_variables = {
            "LaunchConfiguration": {
                "LaunchConfiguration": self.launch_config,
            },

# Path: stacker_blueprints/asg.py
# class FlexibleAutoScalingGroup(Blueprint):
#     """ A more flexible AutoscalingGroup Blueprint.
# 
#     Uses TroposphereTypes to make creating AutoscalingGroups and their
#     associated LaunchConfiguration more flexible. This comes at the price of
#     doing less for you.
#     """
#     VARIABLES = {
#         "LaunchConfiguration": {
#             "type": TroposphereType(autoscaling.LaunchConfiguration),
#             "description": "The LaunchConfiguration for the autoscaling "
#                            "group.",
#         },
#         "AutoScalingGroup": {
#             "type": TroposphereType(autoscaling.AutoScalingGroup),
#             "description": "The Autoscaling definition. Do not provide a "
#                            "LaunchConfiguration parameter, that will be "
#                            "automatically added from the LaunchConfiguration "
#                            "Variable.",
#         },
#     }
# 
#     def create_launch_configuration(self):
#         t = self.template
#         variables = self.get_variables()
#         self.launch_config = t.add_resource(variables["LaunchConfiguration"])
#         t.add_output(
#             Output("LaunchConfiguration", Value=self.launch_config.Ref())
#         )
# 
#     def add_launch_config_variable(self, asg):
#         if getattr(asg, "LaunchConfigurationName", False):
#             raise ValueError("Do not provide a LaunchConfigurationName "
#                              "variable for the AutoScalingGroup config.")
# 
#         asg.LaunchConfigurationName = self.launch_config.Ref()
#         return asg
# 
#     def create_autoscaling_group(self):
#         t = self.template
#         variables = self.get_variables()
#         asg = variables["AutoScalingGroup"]
#         asg = self.add_launch_config_variable(asg)
#         t.add_resource(asg)
#         t.add_output(Output("AutoScalingGroup", Value=asg.Ref()))
# 
#     def create_template(self):
#         self.create_launch_configuration()
#         self.create_autoscaling_group()


# Path: tests/test_asg.py
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.asg import FlexibleAutoScalingGroup
from stacker.blueprints.testutil import BlueprintTestCase




class TestBlueprint(BlueprintTestCase):
    def setUp(self):
        self.launch_config = {
            "ImageId": "i-abc1234",
            "InstanceType": "m3.medium",
            "KeyName": "mock_ssh_key",
            "SecurityGroups": ["sg-abc1234", "sg-bcd2345"],
        }
        self.asg_config = {
            "MinSize": 1,
            "MaxSize": 3,
        }

        self.common_variables = {
            "LaunchConfiguration": {
                "LaunchConfiguration": self.launch_config,
            },

            "AutoScalingGroup": {