Best Python code snippet using localstack_python
transit_gateway_attachments.py
Source:transit_gateway_attachments.py  
...154        return template.render(155            method_name="DeleteTransitGatewayPeeringAttachment",156            transit_gateway_peering_attachment=transit_gateway_peering_attachment,157        )158    def reject_transit_gateway_peering_attachment(self):159        transit_gateway_attachment_id = self._get_param("TransitGatewayAttachmentId")160        transit_gateway_peering_attachment = self.ec2_backend.reject_transit_gateway_peering_attachment(161            transit_gateway_attachment_id=transit_gateway_attachment_id162        )163        template = self.response_template(TRANSIT_GATEWAY_PEERING_ATTACHMENT)164        return template.render(165            method_name="RejectTransitGatewayPeeringAttachment",166            transit_gateway_peering_attachment=transit_gateway_peering_attachment,167        )168CREATE_TRANSIT_GATEWAY_VPC_ATTACHMENT = """<CreateTransitGatewayVpcAttachmentResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">169        <requestId>9b5766ac-2af6-4b92-9a8a-4d74ae46ae79</requestId>170        <transitGatewayVpcAttachment>171            <createTime>{{ transit_gateway_attachment.create_time }}</createTime>172            <options>173                <applianceModeSupport>{{ transit_gateway_attachment.options.ApplianceModeSupport }}</applianceModeSupport>174                <dnsSupport>{{ transit_gateway_attachment.options.DnsSupport }}</dnsSupport>...test_transit_gateway_peering_attachments.py
Source:test_transit_gateway_peering_attachments.py  
...90    find_none = ec2.describe_transit_gateway_peering_attachments(91        Filters=[{"Name": "state", "Values": ["unknown"]}]92    )["TransitGatewayPeeringAttachments"]93    find_none.should.equal([])94    ec2.reject_transit_gateway_peering_attachment(TransitGatewayAttachmentId=attchmnt2)95    find_available = ec2.describe_transit_gateway_peering_attachments(96        TransitGatewayAttachmentIds=[attchmnt1, attchmnt2],97        Filters=[{"Name": "state", "Values": ["available"]}],98    )["TransitGatewayPeeringAttachments"]99    [a["TransitGatewayAttachmentId"] for a in find_available].should.equal([attchmnt1])100@mock_ec2101def test_create_and_accept_transit_gateway_peering_attachment():102    ec2 = boto3.client("ec2", region_name="us-west-1")103    gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[104        "TransitGateway"105    ]["TransitGatewayId"]106    gateway_id2 = ec2.create_transit_gateway(Description="my second gateway")[107        "TransitGateway"108    ]["TransitGatewayId"]109    attchment_id = create_peering_attachment(ec2, gateway_id1, gateway_id2)110    ec2.accept_transit_gateway_peering_attachment(111        TransitGatewayAttachmentId=attchment_id112    )113    attachment = ec2.describe_transit_gateway_peering_attachments(114        TransitGatewayAttachmentIds=[attchment_id]115    )["TransitGatewayPeeringAttachments"][0]116    attachment.should.have.key("TransitGatewayAttachmentId").equal(attchment_id)117    attachment.should.have.key("State").equal("available")118@mock_ec2119def test_create_and_reject_transit_gateway_peering_attachment():120    ec2 = boto3.client("ec2", region_name="us-west-1")121    gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[122        "TransitGateway"123    ]["TransitGatewayId"]124    gateway_id2 = ec2.create_transit_gateway(Description="my second gateway")[125        "TransitGateway"126    ]["TransitGatewayId"]127    attchment_id = create_peering_attachment(ec2, gateway_id1, gateway_id2)128    ec2.reject_transit_gateway_peering_attachment(129        TransitGatewayAttachmentId=attchment_id130    )131    attachment = ec2.describe_transit_gateway_peering_attachments(132        TransitGatewayAttachmentIds=[attchment_id]133    )["TransitGatewayPeeringAttachments"][0]134    attachment.should.have.key("TransitGatewayAttachmentId").equal(attchment_id)135    attachment.should.have.key("State").equal("rejected")136@mock_ec2137def test_create_and_delete_transit_gateway_peering_attachment():138    ec2 = boto3.client("ec2", region_name="us-west-1")139    gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[140        "TransitGateway"141    ]["TransitGatewayId"]142    gateway_id2 = ec2.create_transit_gateway(Description="my second gateway")[...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!!
