#NEWLINE# @ mock_cloudformation ( ) #NEWLINE# @ mock_sns ( ) #NEWLINE# def test_sns_topic( ) : #NEWLINE# #INDENT# dummy_template = { #NEWLINE# #INDENT# 'AWSTemplateFormatVersion' : '2010-09-09' , #NEWLINE# 'Resources' : { #NEWLINE# #INDENT# 'MySNSTopic' : { #NEWLINE# #INDENT# 'Type' : 'AWS::SNS::Topic' , #NEWLINE# 'Properties' : { #NEWLINE# #INDENT# 'Subscription' : [ { #NEWLINE# #INDENT# 'Endpoint' : 'https://example.com' , #NEWLINE# 'Protocol' : 'https' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'TopicName' : 'my_topics' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'Outputs' : { #NEWLINE# #INDENT# 'topic_name' : { #NEWLINE# #INDENT# 'Value' : { #NEWLINE# #INDENT# 'Fn::GetAtt' : [ 'MySNSTopic' , 'TopicName' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'topic_arn' : { #NEWLINE# #INDENT# 'Value' : { #NEWLINE# #INDENT# 'Ref' : 'MySNSTopic' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# template_json = json . dumps ( dummy_template ) #NEWLINE# conn = boto . cloudformation . connect_to_region ( 'us-west-1' ) #NEWLINE# stack = conn . create_stack ( 'test_stack' , template_body = template_json ) #NEWLINE# sns_conn = boto . sns . connect_to_region ( 'us-west-1' ) #NEWLINE# topics = sns_conn . get_all_topics ( ) [ 'ListTopicsResponse' ] [ 'ListTopicsResult' ] [ 'Topics' ] #NEWLINE# topics . should . have . length_of ( 1 ) #NEWLINE# topic_arn = topics [ 0 ] [ 'TopicArn' ] #NEWLINE# topic_arn . should . contain ( 'my_topics' ) #NEWLINE# subscriptions = sns_conn . get_all_subscriptions ( ) [ 'ListSubscriptionsResponse' ] [ 'ListSubscriptionsResult' ] [ 'Subscriptions' ] #NEWLINE# subscriptions . should . have . length_of ( 1 ) #NEWLINE# subscription = subscriptions [ 0 ] #NEWLINE# subscription [ 'TopicArn' ] . should . equal ( topic_arn ) #NEWLINE# subscription [ 'Protocol' ] . should . equal ( 'https' ) #NEWLINE# subscription [ 'SubscriptionArn' ] . should . contain ( topic_arn ) #NEWLINE# subscription [ 'Endpoint' ] . should . equal ( 'https://example.com' ) #NEWLINE# stack = conn . describe_stacks ( ) [ 0 ] #NEWLINE# topic_name_output = [ x for x in stack . outputs if ( x . key == 'topic_name' ) ] [ 0 ] #NEWLINE# topic_name_output . value . should . equal ( 'my_topics' ) #NEWLINE# topic_arn_output = [ x for x in stack . outputs if ( x . key == 'topic_arn' ) ] [ 0 ] #NEWLINE# topic_arn_output . value . should . equal ( topic_arn )