How to use describe_carrier_gateways method in localstack

Best Python code snippet using localstack_python

test_carrier_gateways.py

Source:test_carrier_gateways.py Github

copy

Full Screen

...9def test_describe_carrier_gateways_none():10 if settings.TEST_SERVER_MODE:11 raise SkipTest("ServerMode is not guaranteed to be empty")12 ec2 = boto3.client("ec2", region_name="us-east-1")13 ec2.describe_carrier_gateways()["CarrierGateways"].should.equal([])14@mock_ec215def test_describe_carrier_gateways_multiple():16 client = boto3.client("ec2", region_name="us-east-1")17 ec2 = boto3.resource("ec2", region_name="us-east-1")18 vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")19 cg1 = client.create_carrier_gateway(VpcId=vpc.id)["CarrierGateway"]20 cg2 = client.create_carrier_gateway(VpcId=vpc.id)["CarrierGateway"]21 gateways = client.describe_carrier_gateways()["CarrierGateways"]22 gateway_ids = [g["CarrierGatewayId"] for g in gateways]23 gateway_ids.should.contain(cg1["CarrierGatewayId"])24 gateway_ids.should.contain(cg2["CarrierGatewayId"])25 find_one = client.describe_carrier_gateways(26 CarrierGatewayIds=[cg1["CarrierGatewayId"]]27 )["CarrierGateways"]28 find_one.should.have.length_of(1)29 find_one[0]["CarrierGatewayId"].should.equal(cg1["CarrierGatewayId"])30 find_one = client.describe_carrier_gateways(31 CarrierGatewayIds=[cg2["CarrierGatewayId"], "non-existant"]32 )["CarrierGateways"]33 find_one.should.have.length_of(1)34 find_one[0]["CarrierGatewayId"].should.equal(cg2["CarrierGatewayId"])35@mock_ec236def test_create_carrier_gateways_without_tags():37 client = boto3.client("ec2", region_name="us-east-1")38 ec2 = boto3.resource("ec2", region_name="us-east-1")39 vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")40 cg = client.create_carrier_gateway(VpcId=vpc.id)["CarrierGateway"]41 cg.should.have.key("CarrierGatewayId").match("cagw-[a-z0-9]+")42 cg.should.have.key("VpcId").equal(vpc.id)43 cg.should.have.key("State").equal("available")44 cg.should.have.key("OwnerId").equal(ACCOUNT_ID)45 cg.should.have.key("Tags").equal([])46@mock_ec247def test_create_carrier_gateways_with_tags():48 client = boto3.client("ec2", region_name="us-east-1")49 ec2 = boto3.resource("ec2", region_name="us-east-1")50 vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")51 cg = client.create_carrier_gateway(52 VpcId=vpc.id,53 TagSpecifications=[54 {"ResourceType": "CarrierGateway", "Tags": [{"Key": "tk", "Value": "tv"}]}55 ],56 )["CarrierGateway"]57 cg.should.have.key("CarrierGatewayId").match("cagw-[a-z0-9]+")58 cg.should.have.key("VpcId").equal(vpc.id)59 cg.should.have.key("State").equal("available")60 cg.should.have.key("OwnerId").equal(ACCOUNT_ID)61 cg.should.have.key("Tags").should.equal([{"Key": "tk", "Value": "tv"}])62@mock_ec263def test_create_carrier_gateways_invalid_vpc():64 ec2 = boto3.client("ec2", region_name="us-east-1")65 with pytest.raises(ClientError) as exc:66 ec2.create_carrier_gateway(VpcId="vpc-asdf")67 err = exc.value.response["Error"]68 err["Code"].should.equal("InvalidVpcID.NotFound")69 err["Message"].should.equal("VpcID vpc-asdf does not exist.")70@mock_ec271def test_delete_carrier_gateways():72 client = boto3.client("ec2", region_name="us-east-1")73 ec2 = boto3.resource("ec2", region_name="us-east-1")74 vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")75 cg = client.create_carrier_gateway(VpcId=vpc.id)["CarrierGateway"]76 client.delete_carrier_gateway(CarrierGatewayId=cg["CarrierGatewayId"])77 gateways = client.describe_carrier_gateways()["CarrierGateways"]78 gateway_ids = [g["CarrierGatewayId"] for g in gateways]...

Full Screen

Full Screen

carrier_gateways.py

Source:carrier_gateways.py Github

copy

Full Screen

...14 carrier_gateway_id = self._get_param("CarrierGatewayId")15 carrier_gateway = self.ec2_backend.delete_carrier_gateway(carrier_gateway_id)16 template = self.response_template(DELETE_CARRIER_GATEWAY_RESPONSE)17 return template.render(carrier_gateway=carrier_gateway)18 def describe_carrier_gateways(self):19 carrier_gateway_ids = self._get_multi_param("CarrierGatewayId")20 filters = filters_from_querystring(self.querystring)21 carrier_gateways = self.ec2_backend.describe_carrier_gateways(22 carrier_gateway_ids, filters23 )24 template = self.response_template(DESCRIBE_CARRIER_GATEWAYS_RESPONSE)25 return template.render(carrier_gateways=carrier_gateways)26CREATE_CARRIER_GATEWAY_RESPONSE = """<CreateCarrierGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">27 <requestId>c617595f-6c29-4a00-a941-example</requestId>28 <carrierGateway>29 <state>{{ carrier_gateway.state }}</state>30 <vpcId>{{ carrier_gateway.vpc_id }}</vpcId>31 <carrierGatewayId>{{ carrier_gateway.id }}</carrierGatewayId>32 <ownerId>{{ carrier_gateway.owner_id }}</ownerId>33 <tagSet>34 {% for tag in carrier_gateway.get_tags() %}35 <item>...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful