Repository: getmoto/moto

Issue:
Routes: Uncomment VPC Peering Connection test dependent on Boto > 2.32.1
One of the tests for routes is for a route to VPC Peering Connection, which will be supported in Boto 2.32.2, though that version is not yet packaged and released.

Once a new https://github.com/boto/boto version is released, then `test_routes_vpc_peering_connection` in `tests/test_ec2/test_route_tables.py` should be uncommented, the `@requires_boto_gte("2.32.2")` version number should be confirmed (in case Boto releases as "2.33.0" instead, for instance) and `.travis.yml` should be updated with the new Boto version as well.

It probably makes sense to simply change `BOTO_VERSION=2.32.1` to the new version number, rather than adding a new BOTO_VERSION entry, since this version is already the "VPC peering connection" version.



Discussion:

Resolving patch:
diff --git a/moto/ec2/responses/route_tables.py b/moto/ec2/responses/route_tables.py
--- a/moto/ec2/responses/route_tables.py
+++ b/moto/ec2/responses/route_tables.py
@@ -144,6 +144,7 @@ def replace_route_table_association(self):
                   <state>active</state>
                 {% endif %}
                 {% if route.vpc_pcx %}
+                  <vpcPeeringConnectionId>{{ route.vpc_pcx.id }}</vpcPeeringConnectionId>
                   <origin>CreateRoute</origin>
                   <state>blackhole</state>
                 {% endif %}


Test patch:
diff --git a/tests/test_ec2/test_route_tables.py b/tests/test_ec2/test_route_tables.py
--- a/tests/test_ec2/test_route_tables.py
+++ b/tests/test_ec2/test_route_tables.py
@@ -218,28 +218,29 @@ def test_routes_not_supported():
     conn.replace_route.when.called_with(main_route_table.id, ROUTE_CIDR, interface_id='eni-1234abcd').should.throw(NotImplementedError)
 
 
-#@requires_boto_gte("2.32.2")
-#@mock_ec2
-#def test_routes_vpc_peering_connection():
-#    conn = boto.connect_vpc('the_key', 'the_secret')
-#    vpc = conn.create_vpc("10.0.0.0/16")
-#    main_route_table = conn.get_all_route_tables(filters={'association.main':'true','vpc-id':vpc.id})[0]
-#    local_route = main_route_table.routes[0]
-#    ROUTE_CIDR = "10.0.0.4/24"
-#
-#    peer_vpc = conn.create_vpc("11.0.0.0/16")
-#    vpc_pcx = conn.create_vpc_peering_connection(vpc.id, peer_vpc.id)
-#
-#    conn.create_route(main_route_table.id, ROUTE_CIDR, vpc_peering_connection_id=vpc_pcx.id)
-#
-#    # Refresh route table
-#    main_route_table = conn.get_all_route_tables(main_route_table.id)[0]
-#    new_routes = [route for route in main_route_table.routes if route.destination_cidr_block != vpc.cidr_block]
-#    new_routes.should.have.length_of(1)
-#
-#    new_route = new_routes[0]
-#    new_route.gateway_id.should.be.none
-#    new_route.instance_id.should.be.none
-#    new_route.state.should.equal('blackhole')
-#    new_route.destination_cidr_block.should.equal(ROUTE_CIDR)
+@requires_boto_gte("2.34.0")
+@mock_ec2
+def test_routes_vpc_peering_connection():
+    conn = boto.connect_vpc('the_key', 'the_secret')
+    vpc = conn.create_vpc("10.0.0.0/16")
+    main_route_table = conn.get_all_route_tables(filters={'association.main':'true','vpc-id':vpc.id})[0]
+    local_route = main_route_table.routes[0]
+    ROUTE_CIDR = "10.0.0.4/24"
+
+    peer_vpc = conn.create_vpc("11.0.0.0/16")
+    vpc_pcx = conn.create_vpc_peering_connection(vpc.id, peer_vpc.id)
+
+    conn.create_route(main_route_table.id, ROUTE_CIDR, vpc_peering_connection_id=vpc_pcx.id)
+
+    # Refresh route table
+    main_route_table = conn.get_all_route_tables(main_route_table.id)[0]
+    new_routes = [route for route in main_route_table.routes if route.destination_cidr_block != vpc.cidr_block]
+    new_routes.should.have.length_of(1)
+
+    new_route = new_routes[0]
+    new_route.gateway_id.should.be.none
+    new_route.instance_id.should.be.none
+    new_route.vpc_peering_connection_id.should.equal(vpc_pcx.id)
+    new_route.state.should.equal('blackhole')
+    new_route.destination_cidr_block.should.equal(ROUTE_CIDR)