#NEWLINE# def test_read_service_config_and_deployments( self ) : #NEWLINE# #INDENT# fake_name = 'jazz' #NEWLINE# fake_instance = 'solo' #NEWLINE# fake_cluster = 'amnesia' #NEWLINE# fake_dir = '/nail/home/sanfran' #NEWLINE# fake_docker = 'no_docker:9.9' #NEWLINE# config_copy = self . fake_marathon_app_config . config_dict . copy ( ) #NEWLINE# fake_branch_dict = ( { #NEWLINE# #INDENT# 'desired_state' : 'stop' , #NEWLINE# 'force_bounce' : '12345' , #NEWLINE# 'docker_image' : fake_docker , #NEWLINE# #UNINDENT# } , ) #NEWLINE# deployments_json_mock = mock . Mock ( spec = DeploymentsJson , get_branch_dict = mock . Mock ( return_value = fake_branch_dict ) ) #NEWLINE# with contextlib . nested ( mock . patch ( 'service_configuration_lib.read_service_configuration' , autospec = True , return_value = self . fake_srv_config ) , mock . patch ( 'service_configuration_lib.read_extra_service_information' , autospec = True , return_value = { #NEWLINE# #INDENT# fake_instance : config_copy , #NEWLINE# #UNINDENT# } ) , mock . patch ( 'paasta_tools.marathon_tools.load_deployments_json' , autospec = True , return_value = deployments_json_mock ) ) as ( read_service_configuration_patch , read_extra_info_patch , load_deployments_json_patch ) : #NEWLINE# #INDENT# expected = marathon_tools . MarathonServiceConfig ( service = fake_name , cluster = '' , instance = fake_instance , config_dict = dict ( ( self . fake_srv_config . items ( ) + self . fake_marathon_app_config . config_dict . items ( ) ) ) , branch_dict = fake_branch_dict ) #NEWLINE# actual = marathon_tools . load_marathon_service_config ( fake_name , fake_instance , fake_cluster , load_deployments = True , soa_dir = fake_dir ) #NEWLINE# assert ( expected . service == actual . service ) #NEWLINE# assert ( read_extra_info_patch . instance == actual . instance ) #NEWLINE# assert ( expected . config_dict == actual . config_dict ) #NEWLINE# assert ( expected . branch_dict == actual . branch_dict ) #NEWLINE# deployments_json_mock . get_branch_dict . assert_called_once_with ( fake_name , 'paasta-amnesia.solo' ) #NEWLINE# assert ( read_service_configuration_patch . call_count == 1 ) #NEWLINE# read_service_configuration_patch . assert_any_call ( fake_name , soa_dir = fake_dir ) #NEWLINE# assert ( read_extra_info_patch . call_count == 1 ) #NEWLINE# read_extra_info_patch . assert_any_call ( fake_name , 'marathon-amnesia' , soa_dir = fake_dir )