Best Python code snippet using localstack_python
test_virtual_private_gateways.py
Source:test_virtual_private_gateways.py  
...46    gateway_id = gateway["VpnGateway"]["VpnGatewayId"]4748    ec2.attach_vpn_gateway(VpcId=vpc_id, VpnGatewayId=gateway_id)4950    gateways = ec2.describe_vpn_gateways(51        Filters=[{"Name": "attachment.vpc-id", "Values": [vpc_id]}]52    )5354    gateways["VpnGateways"].should.have.length_of(1)55    gateways["VpnGateways"][0]["VpnGatewayId"].should.equal(gateway_id)56    gateways["VpnGateways"][0]["VpcAttachments"].should.contain(57        {"State": "attached", "VpcId": vpc_id}58    )596061@mock_ec262def test_describe_vpn_connections_state_filter_attached():63    """ describe_vpn_gateways attachment.state filter - match attached """6465    ec2 = boto3.client("ec2", region_name="us-east-1")6667    vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")68    vpc_id = vpc["Vpc"]["VpcId"]69    gateway = ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")70    gateway_id = gateway["VpnGateway"]["VpnGatewayId"]7172    ec2.attach_vpn_gateway(VpcId=vpc_id, VpnGatewayId=gateway_id)7374    gateways = ec2.describe_vpn_gateways(75        Filters=[{"Name": "attachment.state", "Values": ["attached"]}]76    )7778    gateways["VpnGateways"].should.have.length_of(1)79    gateways["VpnGateways"][0]["VpnGatewayId"].should.equal(gateway_id)80    gateways["VpnGateways"][0]["VpcAttachments"].should.contain(81        {"State": "attached", "VpcId": vpc_id}82    )838485@mock_ec286def test_describe_vpn_connections_state_filter_deatched():87    """ describe_vpn_gateways attachment.state filter - don't match detatched """8889    ec2 = boto3.client("ec2", region_name="us-east-1")9091    vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")92    vpc_id = vpc["Vpc"]["VpcId"]93    gateway = ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")94    gateway_id = gateway["VpnGateway"]["VpnGatewayId"]9596    ec2.attach_vpn_gateway(VpcId=vpc_id, VpnGatewayId=gateway_id)9798    gateways = ec2.describe_vpn_gateways(99        Filters=[{"Name": "attachment.state", "Values": ["detached"]}]100    )101102    gateways["VpnGateways"].should.have.length_of(0)103104105@mock_ec2106def test_describe_vpn_connections_id_filter_match():107    """ describe_vpn_gateways vpn-gateway-id filter - match correct id """108109    ec2 = boto3.client("ec2", region_name="us-east-1")110111    gateway = ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")112    gateway_id = gateway["VpnGateway"]["VpnGatewayId"]113114    gateways = ec2.describe_vpn_gateways(115        Filters=[{"Name": "vpn-gateway-id", "Values": [gateway_id]}]116    )117118    gateways["VpnGateways"].should.have.length_of(1)119    gateways["VpnGateways"][0]["VpnGatewayId"].should.equal(gateway_id)120121122@mock_ec2123def test_describe_vpn_connections_id_filter_miss():124    """ describe_vpn_gateways vpn-gateway-id filter - don't match """125126    ec2 = boto3.client("ec2", region_name="us-east-1")127128    ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")129130    gateways = ec2.describe_vpn_gateways(131        Filters=[{"Name": "vpn-gateway-id", "Values": ["unknown_gateway_id"]}]132    )133134    gateways["VpnGateways"].should.have.length_of(0)135136137@mock_ec2138def test_describe_vpn_connections_type_filter_match():139    """ describe_vpn_gateways type filter - match """140141    ec2 = boto3.client("ec2", region_name="us-east-1")142143    gateway = ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")144    gateway_id = gateway["VpnGateway"]["VpnGatewayId"]145146    gateways = ec2.describe_vpn_gateways(147        Filters=[{"Name": "type", "Values": ["ipsec.1"]}]148    )149150    gateways["VpnGateways"].should.have.length_of(1)151    gateways["VpnGateways"][0]["VpnGatewayId"].should.equal(gateway_id)152153154@mock_ec2155def test_describe_vpn_connections_type_filter_miss():156    """ describe_vpn_gateways type filter - don't match """157158    ec2 = boto3.client("ec2", region_name="us-east-1")159160    ec2.create_vpn_gateway(AvailabilityZone="us-east-1a", Type="ipsec.1")161162    gateways = ec2.describe_vpn_gateways(163        Filters=[{"Name": "type", "Values": ["unknown_type"]}]164    )165166    gateways["VpnGateways"].should.have.length_of(0)167168169@mock_ec2_deprecated170def test_vpn_gateway_vpc_attachment():171    conn = boto.connect_vpc("the_key", "the_secret")172    vpc = conn.create_vpc("10.0.0.0/16")173    vpn_gateway = conn.create_vpn_gateway("ipsec.1", "us-east-1a")174175    conn.attach_vpn_gateway(vpn_gateway_id=vpn_gateway.id, vpc_id=vpc.id)176
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
