#NEWLINE# def test_get_marathon_services_running_here_for_nerve_when_not_in_smartstack( self ) : #NEWLINE# #INDENT# cluster = 'edelweiss' #NEWLINE# soa_dir = 'the_sound_of_music' #NEWLINE# fake_marathon_services = [ ( 'no_test' , 'left_behind' , 1111 ) , ( 'no_docstrings' , 'forever_abandoned' , 2222 ) ] #NEWLINE# namespaces = [ 'dos' , 'uno' ] #NEWLINE# nerve_dicts = [ marathon_tools . ServiceNamespaceConfig ( { #NEWLINE# #INDENT# 'binary' : 1 , #NEWLINE# #UNINDENT# } ) , marathon_tools . ServiceNamespaceConfig ( { #NEWLINE# #INDENT# 'clock' : 0 , #NEWLINE# 'proxy_port' : 6666 , #NEWLINE# #UNINDENT# } ) ] #NEWLINE# expected = [ ( 'no_test.uno' , { #NEWLINE# #INDENT# 'clock' : 0 , #NEWLINE# 'port' : 1111 , #NEWLINE# 'proxy_port' : 6666 , #NEWLINE# #UNINDENT# } ) ] #NEWLINE# with contextlib . nested ( mock . patch ( 'paasta_tools.marathon_tools.marathon_services_running_here' , autospec = True , return_value = fake_marathon_services ) , mock . patch ( 'paasta_tools.marathon_tools.read_namespace_for_service_instance' , autospec = True , side_effect = ( lambda a , b , c , d : namespaces . pop ( ) ) ) , mock . patch ( 'paasta_tools.marathon_tools.load_service_namespace_config' , autospec = True , side_effect = ( lambda a , b , c : nerve_dicts . pop ( ) ) ) ) as ( mara_srvs_here_patch , get_namespace_patch , read_ns_config_patch ) : #NEWLINE# #INDENT# actual = marathon_tools . get_marathon_services_running_here_for_nerve ( cluster , soa_dir ) #NEWLINE# assert ( expected == actual ) #NEWLINE# mara_srvs_here_patch . assert_called_once_with ( ) #NEWLINE# get_namespace_patch . assert_any_call ( 'no_test' , 'left_behind' , cluster , soa_dir ) #NEWLINE# get_namespace_patch . assert_any_call ( 'no_docstrings' , 'forever_abandoned' , cluster , soa_dir ) #NEWLINE# assert ( get_namespace_patch . call_count == 2 ) #NEWLINE# read_ns_config_patch . assert_any_call ( 'no_test' , 'uno' , soa_dir ) #NEWLINE# read_ns_config_patch . assert_any_call ( 'no_docstrings' , 'dos' , soa_dir ) #NEWLINE# assert ( read_ns_config_patch . call_count == 2 )