def test_get_vpcs(self): # This actually uses the demo data files provided json_blob = {u'id': 111111111111, u'name': u'demo'} account = Account(None, json_blob) region = Region(account, { "Endpoint": "ec2.us-east-1.amazonaws.com", "RegionName": "us-east-1" }) assert_equal([{ "VpcId": "vpc-12345678", "Tags": [{ "Value": "Prod", "Key": "Name" }], "InstanceTenancy": "default", "CidrBlockAssociationSet": [{ "AssociationId": "vpc-cidr-assoc-12345678", "CidrBlock": "10.0.0.0/16", "CidrBlockState": { "State": "associated" } }], "State": "available", "DhcpOptionsId": "dopt-12345678", "CidrBlock": "10.0.0.0/16", "IsDefault": True }], get_vpcs(region, {}))
def test_get_ec2s(self): # This actually uses the demo data files provided json_blob = {u'id': 111111111111, u'name': u'demo'} account = Account(None, json_blob) region = Region(account, {"Endpoint": "ec2.us-east-1.amazonaws.com", "RegionName": "us-east-1"}) vpc = Vpc(region, get_vpcs(region, {})[0]) subnet = Subnet(vpc, {"SubnetId": "subnet-00000001", "CidrBlock": "10.0.0.0/24", "Tags": [{"Value": "Public a1", "Key": "Name"}]})
def test_get_ec2s(self): # This actually uses the demo data files provided json_blob = {u'id': 111111111111, u'name': u'demo'} account = Account(None, json_blob) region = Region(account, { "Endpoint": "ec2.us-east-1.amazonaws.com", "RegionName": "us-east-1" }) vpc = Vpc(region, get_vpcs(region, {})[0]) subnet = Subnet( vpc, { "SubnetId": "subnet-00000001", "CidrBlock": "10.0.0.0/24", "Tags": [{ "Value": "Public a1", "Key": "Name" }] }) instances_passed = get_ec2s(subnet, {"tags": ["Name=Bastion"]}) assert_equal(len(instances_passed), 1) instances_filtered = get_ec2s( subnet, {"tags": ["NonexistentTagName=NonexistentTagValue"]}) assert_equal(len(instances_filtered), 0)