#NEWLINE# def test_reset_password_for_user_that_exists( self ) : #NEWLINE# #INDENT# builtins = flexmock ( sys . modules [ '__builtin__' ] ) #NEWLINE# builtins . should_call ( 'open' ) #NEWLINE# secret_key_location = LocalState . get_secret_key_location ( self . keyname ) #NEWLINE# fake_secret = flexmock ( name = 'fake_secret' ) #NEWLINE# fake_secret . should_receive ( 'read' ) . and_return ( 'the secret' ) #NEWLINE# builtins . should_receive ( 'open' ) . with_args ( secret_key_location , 'r' ) . and_return ( fake_secret ) #NEWLINE# builtins . should_receive ( 'raw_input' ) . and_return ( 'boo@foo.goo' ) #NEWLINE# flexmock ( getpass ) #NEWLINE# getpass . should_receive ( 'getpass' ) . and_return ( 'the password' ) #NEWLINE# flexmock ( os . path ) #NEWLINE# os . path . should_call ( 'exists' ) #NEWLINE# os . path . should_receive ( 'exists' ) . with_args ( LocalState . get_locations_json_location ( self . keyname ) ) . and_return ( True ) #NEWLINE# fake_nodes_json = flexmock ( name = 'fake_secret' ) #NEWLINE# fake_nodes_json . should_receive ( 'read' ) . and_return ( json . dumps ( [ { #NEWLINE# #INDENT# 'public_ip' : 'public1' , #NEWLINE# 'private_ip' : 'private1' , #NEWLINE# 'jobs' : [ 'login' , 'db_master' ] , #NEWLINE# #UNINDENT# } ] ) ) #NEWLINE# builtins . should_receive ( 'open' ) . with_args ( LocalState . get_locations_json_location ( self . keyname ) , 'r' ) . and_return ( fake_nodes_json ) #NEWLINE# fake_appcontroller = flexmock ( name = 'fake_appcontroller' ) #NEWLINE# fake_appcontroller . should_receive ( 'status' ) . with_args ( 'the secret' ) . and_return ( 'nothing interesting here' ) . and_return ( 'Database is at not-up-yet' ) . and_return ( 'Database is at public1' ) #NEWLINE# fake_appcontroller . should_receive ( 'reset_password' ) . with_args ( 'boo@foo.goo' , str , 'the secret' ) . and_return ( 'true' ) #NEWLINE# flexmock ( SOAPpy ) #NEWLINE# SOAPpy . should_receive ( 'SOAPProxy' ) . with_args ( 'https://public1:17443' ) . and_return ( fake_appcontroller ) #NEWLINE# argv = [ '--keyname' , builtins . keyname ] #NEWLINE# options = ParseArgs ( argv , self . function ) . args #NEWLINE# AppScaleTools . reset_password ( options )