#NEWLINE# @ mock_ec2 ( ) #NEWLINE# @ mock_redshift ( ) #NEWLINE# @ mock_cloudformation ( ) #NEWLINE# def test_redshift_stack( ) : #NEWLINE# #INDENT# redshift_template_json = json . dumps ( redshift . template ) #NEWLINE# vpc_conn = boto . vpc . connect_to_region ( 'us-west-2' ) #NEWLINE# conn = boto . cloudformation . connect_to_region ( 'us-west-2' ) #NEWLINE# conn . create_stack ( 'redshift_stack' , template_body = redshift_template_json , parameters = [ ( 'DatabaseName' , 'mydb' ) , ( 'ClusterType' , 'multi-node' ) , ( 'NumberOfNodes' , 2 ) , ( 'NodeType' , 'dw1.xlarge' ) , ( 'MasterUsername' , 'myuser' ) , ( 'MasterUserPassword' , 'mypass' ) , ( 'InboundTraffic' , '10.0.0.1/16' ) , ( 'PortNumber' , 5439 ) ] ) #NEWLINE# redshift_conn = boto . redshift . connect_to_region ( 'us-west-2' ) #NEWLINE# cluster_res = redshift_conn . describe_clusters ( ) #NEWLINE# clusters = cluster_res [ 'DescribeClustersResponse' ] [ 'DescribeClustersResult' ] [ 'Clusters' ] #NEWLINE# clusters . should . have . length_of ( 1 ) #NEWLINE# cluster = clusters [ 0 ] #NEWLINE# cluster [ 'DBName' ] . should . equal ( 'mydb' ) #NEWLINE# cluster [ 'NumberOfNodes' ] . should . equal ( 2 ) #NEWLINE# cluster [ 'NodeType' ] . should . equal ( 'dw1.xlarge' ) #NEWLINE# cluster [ 'MasterUsername' ] . should . equal ( 'myuser' ) #NEWLINE# cluster [ 'Port' ] . should . equal ( 5439 ) #NEWLINE# cluster [ 'VpcSecurityGroups' ] . should . have . length_of ( 1 ) #NEWLINE# security_group_id = cluster [ 'VpcSecurityGroups' ] [ 0 ] [ 'VpcSecurityGroupId' ] #NEWLINE# groups = vpc_conn . get_all_security_groups ( group_ids = [ cluster_res ] ) #NEWLINE# groups . should . have . length_of ( 1 ) #NEWLINE# group = groups [ 0 ] #NEWLINE# group . rules . should . have . length_of ( 1 ) #NEWLINE# group . rules [ 0 ] . grants [ 0 ] . cidr_ip . should . equal ( '10.0.0.1/16' )