Merge pull request #172 from DreadPirateShawn/CreateSubnetVPCValidation
Create subnet vpc validation
This commit is contained in:
		
						commit
						8f79d71f3f
					
				
							
								
								
									
										
											BIN
										
									
								
								moto/ec2/.models.py.swp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								moto/ec2/.models.py.swp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -902,6 +902,7 @@ class SubnetBackend(object):
 | 
				
			|||||||
    def create_subnet(self, vpc_id, cidr_block):
 | 
					    def create_subnet(self, vpc_id, cidr_block):
 | 
				
			||||||
        subnet_id = random_subnet_id()
 | 
					        subnet_id = random_subnet_id()
 | 
				
			||||||
        subnet = Subnet(subnet_id, vpc_id, cidr_block)
 | 
					        subnet = Subnet(subnet_id, vpc_id, cidr_block)
 | 
				
			||||||
 | 
					        vpc = self.get_vpc(vpc_id) # Validate VPC exists
 | 
				
			||||||
        self.subnets[subnet_id] = subnet
 | 
					        self.subnets[subnet_id] = subnet
 | 
				
			||||||
        return subnet
 | 
					        return subnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								tests/test_ec2/.test_subnets.py.swp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								tests/test_ec2/.test_subnets.py.swp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -30,6 +30,17 @@ def test_subnets():
 | 
				
			|||||||
    cm.exception.request_id.should_not.be.none
 | 
					    cm.exception.request_id.should_not.be.none
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@mock_ec2
 | 
				
			||||||
 | 
					def test_subnet_create_vpc_validation():
 | 
				
			||||||
 | 
					    conn = boto.connect_vpc('the_key', 'the_secret')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    with assert_raises(EC2ResponseError) as cm:
 | 
				
			||||||
 | 
					        conn.create_subnet("vpc-abcd1234", "10.0.0.0/18")
 | 
				
			||||||
 | 
					    cm.exception.code.should.equal('InvalidVpcID.NotFound')
 | 
				
			||||||
 | 
					    cm.exception.status.should.equal(400)
 | 
				
			||||||
 | 
					    cm.exception.request_id.should_not.be.none
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@mock_ec2
 | 
					@mock_ec2
 | 
				
			||||||
def test_subnet_tagging():
 | 
					def test_subnet_tagging():
 | 
				
			||||||
    conn = boto.connect_vpc('the_key', 'the_secret')
 | 
					    conn = boto.connect_vpc('the_key', 'the_secret')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user