Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Fix my typo and add tests to cover it - I will rebase before merging
Browse files Browse the repository at this point in the history
  • Loading branch information
ashb committed Jun 1, 2015
1 parent 50c4928 commit c573d09
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bootstrap_cfn/config.py
Expand Up @@ -107,7 +107,7 @@ def base_template(self):
})

if 'vpc' in self.data:
t.app_mapping("SubnetConfig", {
t.add_mapping("SubnetConfig", {
"VPC": self.data['vpc']
})
else:
Expand Down
70 changes: 70 additions & 0 deletions tests/tests.py
Expand Up @@ -464,6 +464,76 @@ def test_process(self):
output_names.sort()
compare(output_names, wanted)

mappings = cfn_template['Mappings']
expected = {
'AWSRegion2AMI': {'eu-west-1': {'AMI': 'ami-f0b11187'}},
'SubnetConfig': {
'VPC': {
'CIDR': '10.0.0.0/16',
'SubnetA': '10.0.0.0/20',
'SubnetB': '10.0.16.0/20',
'SubnetC': '10.0.32.0/20',
}
}
}
compare(mappings, expected)

def test_process_with_vpc_config(self):
"""
This isn't the best test, but we at least check that we have the right
Resource names returned
"""
project_config = ProjectConfig(
'tests/sample-project.yaml',
'dev',
'tests/sample-project-passwords.yaml')
project_config.config['vpc'] = {
'CIDR': '172.22.0.0/16',
'SubnetA': '172.22.1.0/24',
'SubnetB': '172.22.2.0/24',
'SubnetC': '172.22.3.0/24',
}
config = ConfigParser(project_config.config, 'my-stack-name')

cfn_template = json.loads(config.process())

wanted = [
"AnotherSG", "AttachGateway", "BaseHostLaunchConfig",
"BaseHostRole", "BaseHostSG", "DNStestdevexternal",
"DNStestdevinternal", "DatabaseSG", "DefaultSGtestdevexternal",
"DefaultSGtestdevinternal", "ELBtestdevexternal",
"ELBtestdevinternal", "InstanceProfile", "InternetGateway",
"Policytestdevexternal", "Policytestdevinternal", "PublicRoute",
"PublicRouteTable", "RDSInstance", "RDSSubnetGroup",
"RolePolicies", "ScalingGroup", "StaticBucket",
"StaticBucketPolicy", "SubnetA", "SubnetB", "SubnetC",
"SubnetRouteTableAssociationA", "SubnetRouteTableAssociationB",
"SubnetRouteTableAssociationC", "VPC"
]

resource_names = cfn_template['Resources'].keys()
resource_names.sort()
compare(resource_names, wanted)

wanted = ["dbhost", "dbport"]
output_names = cfn_template['Outputs'].keys()
output_names.sort()
compare(output_names, wanted)

mappings = cfn_template['Mappings']
expected = {
'AWSRegion2AMI': {'eu-west-1': {'AMI': 'ami-f0b11187'}},
'SubnetConfig': {
'VPC': {
'CIDR': '172.22.0.0/16',
'SubnetA': '172.22.1.0/24',
'SubnetB': '172.22.2.0/24',
'SubnetC': '172.22.3.0/24',
}
}
}
compare(mappings, expected)

def test_process_no_elbs_no_rds(self):
project_config = ProjectConfig('tests/sample-project.yaml', 'dev')
# Assuming there's no ELB defined
Expand Down

0 comments on commit c573d09

Please sign in to comment.