#NEWLINE# def test_replace_route_table( self ) : #NEWLINE# #INDENT# data = self . client . create_subnet ( VpcId = self . vpc_id , CidrBlock = self . SUBNET_CIDR ) #NEWLINE# subnet_id = data [ 'Subnet' ] [ 'SubnetId' ] #NEWLINE# res_clean_subnet = self . addResourceCleanUp ( self . client . delete_subnet , SubnetId = subnet_id ) #NEWLINE# self . get_subnet_waiter ( ) . wait_available ( subnet_id ) #NEWLINE# data = self . client . describe_route_tables ( Filters = [ { #NEWLINE# #INDENT# 'Name' : 'vpc-id' , #NEWLINE# 'Values' : [ self . vpc_id ] , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( 1 , len ( data [ 'RouteTables' ] ) ) #NEWLINE# self . assertEqual ( 1 , len ( data [ 'RouteTables' ] [ 0 ] [ 'Associations' ] ) ) #NEWLINE# default_rt_id = data [ 'RouteTables' ] [ 0 ] [ 'RouteTableId' ] #NEWLINE# main_assoc = data [ 'RouteTables' ] [ 0 ] [ 'Associations' ] [ 0 ] #NEWLINE# self . assertTrue ( main_assoc [ 'Main' ] ) #NEWLINE# main_assoc_id = main_assoc [ 'RouteTableAssociationId' ] #NEWLINE# data = self . client . create_route_table ( VpcId = self . vpc_id ) #NEWLINE# rt_id = rt [ 'RouteTable' ] [ 'RouteTableId' ] #NEWLINE# res_clean_rt = self . addResourceCleanUp ( self . client . delete_route_table , RouteTableId = rt_id ) #NEWLINE# data = self . client . replace_route_table_association ( RouteTableId = rt_id , AssociationId = main_assoc_id ) #NEWLINE# assoc_id = data [ 'NewAssociationId' ] #NEWLINE# res_clean = self . addResourceCleanUp ( self . client . replace_route_table_association , RouteTableId = default_rt_id , AssociationId = assoc_id ) #NEWLINE# data = self . client . describe_route_tables ( Filters = [ { #NEWLINE# #INDENT# 'Name' : 'vpc-id' , #NEWLINE# 'Values' : [ self . vpc_id ] , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( 2 , len ( data [ 'RouteTables' ] ) ) #NEWLINE# for rt in data [ 'RouteTables' ] : #NEWLINE# #INDENT# if ( rt [ 'RouteTableId' ] == rt_id ) : #NEWLINE# #INDENT# self . assertEqual ( 1 , len ( rt [ 'Associations' ] ) ) #NEWLINE# self . assertTrue ( rt [ 'Associations' ] [ 0 ] [ 'Main' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEmpty ( rt . get ( 'Associations' , [ ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertRaises ( 'DependencyViolation' , self . client . delete_route_table , RouteTableId = rt_id ) #NEWLINE# self . assertRaises ( 'InvalidParameterValue' , self . client . disassociate_route_table , AssociationId = assoc_id ) #NEWLINE# data = self . client . replace_route_table_association ( RouteTableId = default_rt_id , AssociationId = assoc_id ) #NEWLINE# self . cancelResourceCleanUp ( res_clean ) #NEWLINE# data = self . client . delete_route_table ( RouteTableId = rt_id ) #NEWLINE# self . cancelResourceCleanUp ( res_clean_rt ) #NEWLINE# data = self . client . delete_subnet ( SubnetId = subnet_id ) #NEWLINE# self . cancelResourceCleanUp ( res_clean_subnet ) #NEWLINE# self . get_subnet_waiter ( ) . wait_delete ( subnet_id )