#NEWLINE# def test_send_event( self ) : #NEWLINE# #INDENT# fake_service = 'fake_service' #NEWLINE# fake_monitoring_overrides = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# fake_check_name = 'fake_check_name' #NEWLINE# fake_status = '42' #NEWLINE# fake_output = 'The http port is not open' #NEWLINE# fake_team = 'fake_team' #NEWLINE# fake_tip = 'fake_tip' #NEWLINE# fake_notification_email = 'fake@notify' #NEWLINE# fake_irc = '#fake' #NEWLINE# fake_soa_dir = '/fake/soa/dir' #NEWLINE# self . fake_cluster = 'fake_cluster' #NEWLINE# fake_sensu_host = 'fake_sensu_host' #NEWLINE# fake_sensu_port = 12345 #NEWLINE# expected_runbook = 'http://y/paasta-troubleshooting' #NEWLINE# expected_check_name = fake_check_name #NEWLINE# expected_kwargs = { #NEWLINE# #INDENT# 'tip' : fake_tip , #NEWLINE# 'notification_email' : fake_notification_email , #NEWLINE# 'irc_channels' : fake_irc , #NEWLINE# 'project' : None , #NEWLINE# 'ticket' : False , #NEWLINE# 'page' : True , #NEWLINE# 'alert_after' : '5m' , #NEWLINE# 'check_every' : '1m' , #NEWLINE# 'realert_every' : ( - 1 ) , #NEWLINE# 'source' : 'paasta-fake_cluster' , #NEWLINE# 'ttl' : None , #NEWLINE# #UNINDENT# } #NEWLINE# with contextlib . nested ( mock . patch ( 'paasta_tools.monitoring_tools.get_team' , return_value = fake_team , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_tip' , return_value = fake_tip , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_notification_email' , return_value = fake_notification_email , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_irc_channels' , return_value = fake_irc , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_ticket' , return_value = False , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_project' , return_value = None , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.get_page' , return_value = True , autospec = True ) , mock . patch ( 'pysensu_yelp.send_event' , autospec = True ) , mock . patch ( 'paasta_tools.monitoring_tools.load_system_paasta_config' , autospec = True ) ) as ( get_team_patch , get_tip_patch , get_notification_email_patch , get_irc_patch , get_ticket_patch , get_project_patch , get_page_patch , pysensu_yelp_send_event_patch , load_system_paasta_config_patch ) : #NEWLINE# #INDENT# load_system_paasta_config_patch . return_value . get_cluster = mock . Mock ( return_value = self . fake_cluster ) #NEWLINE# load_system_paasta_config_patch . return_value . get_sensu_host = mock . Mock ( return_value = fake_sensu_host ) #NEWLINE# load_system_paasta_config_patch . return_value . get_sensu_port = mock . Mock ( return_value = fake_sensu_port ) #NEWLINE# monitoring_tools . send_event ( fake_service , fake_check_name , fake_monitoring_overrides , fake_status , fake_output , fake_soa_dir ) #NEWLINE# get_team_patch . assert_called_once_with ( fake_monitoring_overrides , fake_service , fake_soa_dir ) #NEWLINE# get_tip_patch . assert_called_once_with ( fake_monitoring_overrides , fake_service , fake_soa_dir ) #NEWLINE# get_notification_email_patch . assert_called_once_with ( fake_monitoring_overrides , fake_service , fake_soa_dir ) #NEWLINE# get_irc_patch . assert_called_once_with ( fake_monitoring_overrides , fake_service , fake_soa_dir ) #NEWLINE# get_page_patch . assert_called_once_with ( fake_monitoring_overrides , fake_service , fake_soa_dir ) #NEWLINE# pysensu_yelp_send_event_patch . assert_called_once_with ( expected_check_name , expected_runbook , fake_status , fake_output , fake_team , sensu_host = fake_sensu_host , sensu_port = fake_sensu_port , ** expected_kwargs ) #NEWLINE# load_system_paasta_config_patch . return_value . get_cluster . assert_called_once_with ( )