#NEWLINE# def test_classic_replication_check( ) : #NEWLINE# #INDENT# base_module = 'paasta_tools.monitoring' #NEWLINE# check_classic_module = ( base_module + '.check_classic_service_replication' ) #NEWLINE# read_config_method = ( check_classic_module + '.read_services_configuration' ) #NEWLINE# replication_method = ( check_classic_module + '.get_replication_for_services' ) #NEWLINE# extract_method = ( check_classic_module + '.extract_replication_info' ) #NEWLINE# check_method = ( check_classic_module + '.do_replication_check' ) #NEWLINE# load_system_paasta_config_module = ( check_classic_module + '.load_system_paasta_config' ) #NEWLINE# mock_service_config = { #NEWLINE# #INDENT# 'pow' : { #NEWLINE# #INDENT# 'wat' : 1 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# mock_replication = { #NEWLINE# #INDENT# 'pow' : ( - 1 ) , #NEWLINE# #UNINDENT# } #NEWLINE# mock_monitoring = { #NEWLINE# #INDENT# 'pow' : 'bar' , #NEWLINE# #UNINDENT# } #NEWLINE# mock_check = { #NEWLINE# #INDENT# 'team' : 'testing' , #NEWLINE# 'output' : 'testing looks good' , #NEWLINE# #UNINDENT# } #NEWLINE# with nested ( mock . patch ( read_config_method , return_value = mock_service_config ) , mock . patch ( replication_method , return_value = mock_replication ) , mock . patch ( extract_method , return_value = ( True , mock_monitoring ) ) , mock . patch ( check_method , return_value = mock_check ) , mock . patch ( 'pysensu_yelp.send_event' ) , mock . patch . object ( sys , 'argv' , [ 'check_classic_service_replication.py' ] ) , mock . patch ( load_system_paasta_config_module , return_value = SystemPaastaConfig ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , '/fake/config' ) ) ) as ( _ , _ , _ , mcheck , _ , _ , _ ) : #NEWLINE# #INDENT# with pytest . raises ( SystemExit ) as error : #NEWLINE# #INDENT# check = ClassicServiceReplicationCheck ( ) #NEWLINE# check . run ( ) #NEWLINE# assert mcheck . assert_called_with ( 'pow' , { #NEWLINE# #INDENT# 'wat' : 1 , #NEWLINE# #UNINDENT# } , ( - 1 ) ) #NEWLINE# #UNINDENT# assert ( error . value . code == 0 )