#NEWLINE# def test_update_local_metadata( self ) : #NEWLINE# #INDENT# fake_soap = flexmock ( name = 'fake_soap' ) #NEWLINE# fake_soap . should_receive ( 'get_all_public_ips' ) . with_args ( 'the secret' ) . and_return ( json . dumps ( [ 'public1' ] ) ) #NEWLINE# role_info = [ { #NEWLINE# #INDENT# 'public_ip' : 'public1' , #NEWLINE# 'private_ip' : 'private1' , #NEWLINE# 'jobs' : [ 'shadow' , 'db_master' ] , #NEWLINE# #UNINDENT# } ] #NEWLINE# fake_soap . should_receive ( 'get_role_info' ) . with_args ( 'the secret' ) . and_return ( json . dumps ( role_info ) ) #NEWLINE# flexmock ( SOAPpy ) #NEWLINE# SOAPpy . should_receive ( 'SOAPProxy' ) . with_args ( 'https://public1:17443' ) . and_return ( fake_soap ) #NEWLINE# fake_secret = flexmock ( name = 'fake_secret' ) #NEWLINE# fake_secret . should_receive ( 'read' ) . and_return ( 'the secret' ) #NEWLINE# builtins = flexmock ( sys . modules [ '__builtin__' ] ) #NEWLINE# builtins . should_call ( 'open' ) #NEWLINE# builtins . should_receive ( 'open' ) . with_args ( LocalState . get_secret_key_location ( 'booscale' ) , 'r' ) . and_return ( fake_secret ) #NEWLINE# fake_locations_yaml = flexmock ( name = 'fake_locations_yaml' ) #NEWLINE# fake_locations_yaml . should_receive ( 'write' ) . with_args ( yaml . dump ( { #NEWLINE# #INDENT# 'load_balancer' : 'public1' , #NEWLINE# 'instance_id' : 'i-ABCDEFG' , #NEWLINE# 'secret' : 'the secret' , #NEWLINE# 'infrastructure' : 'ec2' , #NEWLINE# 'group' : 'boogroup' , #NEWLINE# 'ips' : 'public1' , #NEWLINE# 'table' : 'cassandra' , #NEWLINE# 'db_master' : 'node-0' , #NEWLINE# 'zone' : 'my-zone-1b' , #NEWLINE# #UNINDENT# } ) ) . and_return ( ) #NEWLINE# builtins . should_receive ( 'open' ) . with_args ( LocalState . get_locations_yaml_location ( 'booscale' ) , 'w' ) . and_return ( fake_locations_yaml ) #NEWLINE# fake_locations_json = flexmock ( name = 'fake_locations_json' ) #NEWLINE# fake_locations_json . should_receive ( 'write' ) . with_args ( json . dumps ( role_info ) ) . and_return ( ) #NEWLINE# builtins . should_receive ( 'open' ) . with_args ( LocalState . get_locations_json_location ( 'booscale' ) , 'w' ) . and_return ( fake_locations_json ) #NEWLINE# options = flexmock ( name = 'options' , table = 'cassandra' , infrastructure = 'ec2' , keyname = 'booscale' , group = 'boogroup' , zone = 'my-zone-1b' ) #NEWLINE# node_layout = NodeLayout ( options = { #NEWLINE# #INDENT# 'min' : 1 , #NEWLINE# 'max' : 1 , #NEWLINE# 'infrastructure' : 'ec2' , #NEWLINE# 'table' : 'cassandra' , #NEWLINE# #UNINDENT# } ) #NEWLINE# host = 'public1' #NEWLINE# instance_id = 'i-ABCDEFG' #NEWLINE# LocalState . update_local_metadata ( options , fake_locations_json , host , instance_id )