# Path: stacker_blueprints/vpc.py
# class VPC2(Blueprint):
#     """This is a stripped down version of the VPC Blueprint."""
# 
#     VARIABLES = {
#         "VPC": {
#             "type": TroposphereType(ec2.VPC),
#         },
#         "InternalZone": {
#             "type": TroposphereType(route53.HostedZone, optional=True),
#             "description": "The config for an internal zone. If provided, "
#                            "the zone will be created with the VPCs setting "
#                            "set to this VPC.",
#             "default": None,
#         },
#     }
# 
#     def create_vpc(self):
#         t = self.template
#         variables = self.get_variables()
# 
#         self.vpc = t.add_resource(variables["VPC"])
#         t.add_output(Output("VpcId", Value=self.vpc.Ref()))
# 
#         attrs = [
#             "CidrBlock", "CidrBlockAssociations", "DefaultNetworkAcl",
#             "DefaultSecurityGroup", "Ipv6CidrBlocks"
#         ]
#         for attr in attrs:
#             t.add_output(Output(attr, Value=self.vpc.GetAtt(attr)))
# 
#     def create_internet_gateway(self):
#         t = self.template
#         self.gateway = t.add_resource(ec2.InternetGateway("InternetGateway"))
# 
#         t.add_output(
#             Output(
#                 "InternetGatewayId",
#                 Value=self.gateway.Ref(),
#             )
#         )
# 
#         self.gateway_attachment = t.add_resource(
#             ec2.VPCGatewayAttachment(
#                 "VPCGatewayAttachment",
#                 VpcId=self.vpc.Ref(),
#                 InternetGatewayId=self.gateway.Ref(),
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "VPCGatewayAttachmentId",
#                 Value=self.gateway_attachment.Ref(),
#             )
#         )
# 
#     def create_internal_zone(self):
#         t = self.template
#         variables = self.get_variables()
# 
#         self.zone = variables["InternalZone"]
# 
#         if self.zone:
#             hosted_zone_vpc = route53.HostedZoneVPCs(
#                 VPCId=self.vpc.Ref(),
#                 VPCRegion=Region,
#             )
# 
#             self.zone.VPCs = [hosted_zone_vpc, ]
#             t.add_resource(self.zone)
# 
#             t.add_output(
#                 Output(
#                     "InternalZoneId",
#                     Value=self.zone.Ref(),
#                 )
#             )
#             t.add_output(
#                 Output(
#                     "InternalZoneName",
#                     Value=self.zone.Name,
#                 )
#             )
# 
#     def create_dhcp_options(self):
#         t = self.template
# 
#         search_path = NoValue
#         if self.zone:
#             search_path = self.zone.Name
# 
#         self.dhcp_options = t.add_resource(
#             ec2.DHCPOptions(
#                 "DHCPOptions",
#                 DomainName=search_path,
#                 DomainNameServers=["AmazonProvidedDNS", ],
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "DHCPOptionsId",
#                 Value=self.dhcp_options.Ref(),
#             )
#         )
# 
#         self.dhcp_association = t.add_resource(
#             ec2.VPCDHCPOptionsAssociation(
#                 "VPCDHCPOptionsAssociation",
#                 VpcId=self.vpc.Ref(),
#                 DhcpOptionsId=self.dhcp_options.Ref(),
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "VPCDHCPOptionsAssociation",
#                 Value=self.dhcp_association.Ref(),
#             )
#         )
# 
#     def create_template(self):
#         self.create_vpc()
#         self.create_internet_gateway()
#         self.create_internal_zone()
#         self.create_dhcp_options()


from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.vpc import VPC2
from stacker.blueprints.testutil import BlueprintTestCase
from troposphere.route53 import HostedZone


VPC_NAME = "MyVPC"


class TestVPC2(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))
        self.common_variables = {
            "VPC": {
                VPC_NAME: {
                    "CidrBlock": "10.0.0.0/16"
                }
            }
        }

    def create_blueprint(self, name):
        return VPC2(name, self.ctx)


# Path: stacker_blueprints/vpc.py
# class VPC2(Blueprint):
#     """This is a stripped down version of the VPC Blueprint."""
# 
#     VARIABLES = {
#         "VPC": {
#             "type": TroposphereType(ec2.VPC),
#         },
#         "InternalZone": {
#             "type": TroposphereType(route53.HostedZone, optional=True),
#             "description": "The config for an internal zone. If provided, "
#                            "the zone will be created with the VPCs setting "
#                            "set to this VPC.",
#             "default": None,
#         },
#     }
# 
#     def create_vpc(self):
#         t = self.template
#         variables = self.get_variables()
# 
#         self.vpc = t.add_resource(variables["VPC"])
#         t.add_output(Output("VpcId", Value=self.vpc.Ref()))
# 
#         attrs = [
#             "CidrBlock", "CidrBlockAssociations", "DefaultNetworkAcl",
#             "DefaultSecurityGroup", "Ipv6CidrBlocks"
#         ]
#         for attr in attrs:
#             t.add_output(Output(attr, Value=self.vpc.GetAtt(attr)))
# 
#     def create_internet_gateway(self):
#         t = self.template
#         self.gateway = t.add_resource(ec2.InternetGateway("InternetGateway"))
# 
#         t.add_output(
#             Output(
#                 "InternetGatewayId",
#                 Value=self.gateway.Ref(),
#             )
#         )
# 
#         self.gateway_attachment = t.add_resource(
#             ec2.VPCGatewayAttachment(
#                 "VPCGatewayAttachment",
#                 VpcId=self.vpc.Ref(),
#                 InternetGatewayId=self.gateway.Ref(),
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "VPCGatewayAttachmentId",
#                 Value=self.gateway_attachment.Ref(),
#             )
#         )
# 
#     def create_internal_zone(self):
#         t = self.template
#         variables = self.get_variables()
# 
#         self.zone = variables["InternalZone"]
# 
#         if self.zone:
#             hosted_zone_vpc = route53.HostedZoneVPCs(
#                 VPCId=self.vpc.Ref(),
#                 VPCRegion=Region,
#             )
# 
#             self.zone.VPCs = [hosted_zone_vpc, ]
#             t.add_resource(self.zone)
# 
#             t.add_output(
#                 Output(
#                     "InternalZoneId",
#                     Value=self.zone.Ref(),
#                 )
#             )
#             t.add_output(
#                 Output(
#                     "InternalZoneName",
#                     Value=self.zone.Name,
#                 )
#             )
# 
#     def create_dhcp_options(self):
#         t = self.template
# 
#         search_path = NoValue
#         if self.zone:
#             search_path = self.zone.Name
# 
#         self.dhcp_options = t.add_resource(
#             ec2.DHCPOptions(
#                 "DHCPOptions",
#                 DomainName=search_path,
#                 DomainNameServers=["AmazonProvidedDNS", ],
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "DHCPOptionsId",
#                 Value=self.dhcp_options.Ref(),
#             )
#         )
# 
#         self.dhcp_association = t.add_resource(
#             ec2.VPCDHCPOptionsAssociation(
#                 "VPCDHCPOptionsAssociation",
#                 VpcId=self.vpc.Ref(),
#                 DhcpOptionsId=self.dhcp_options.Ref(),
#             )
#         )
# 
#         t.add_output(
#             Output(
#                 "VPCDHCPOptionsAssociation",
#                 Value=self.dhcp_association.Ref(),
#             )
#         )
# 
#     def create_template(self):
#         self.create_vpc()
#         self.create_internet_gateway()
#         self.create_internal_zone()
#         self.create_dhcp_options()


# Path: tests/test_vpc.py
from stacker.context import Context
from stacker.config import Config
from stacker.variables import Variable
from stacker_blueprints.vpc import VPC2
from stacker.blueprints.testutil import BlueprintTestCase
from troposphere.route53 import HostedZone



VPC_NAME = "MyVPC"


class TestVPC2(BlueprintTestCase):
    def setUp(self):
        self.ctx = Context(config=Config({'namespace': 'test'}))
        self.common_variables = {
            "VPC": {
                VPC_NAME: {
                    "CidrBlock": "10.0.0.0/16"
                }
            }
        }

    def create_blueprint(self, name):
        return VPC2(name, self.ctx)


    def generate_variables(self, variable_dict=None):