#NEWLINE# def test_retrieve_loadbalancer_stats( self ) : #NEWLINE# #INDENT# resource = 'loadbalancer' #NEWLINE# cmd = lb . RetrieveLoadBalancerStats ( test_cli20 . MyApp ( sys . stdout ) , None ) #NEWLINE# my_id = self . test_id #NEWLINE# fields = [ 'bytes_in' , 'bytes_out' ] #NEWLINE# args = [ '--fields' , 'bytes_in' , '--fields' , 'bytes_out' , my_id ] #NEWLINE# self . mox . StubOutWithMock ( cmd , 'get_client' ) #NEWLINE# self . mox . StubOutWithMock ( self . client . httpclient , 'request' ) #NEWLINE# cmd . get_client ( ) . MultipleTimes ( ) . AndReturn ( self . client ) #NEWLINE# query = '&' . join ( [ ( 'fields=%s' % field ) for field in fields ] ) #NEWLINE# expected_res = { #NEWLINE# #INDENT# 'stats' : { #NEWLINE# #INDENT# 'bytes_in' : '1234' , #NEWLINE# 'bytes_out' : '4321' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# resstr = self . client . serialize ( expected_res ) #NEWLINE# path = getattr ( self . client , 'lbaas_loadbalancer_path_stats' ) #NEWLINE# return_tup = ( test_cli20 . MyResp ( 200 ) , resstr ) #NEWLINE# self . client . httpclient . request ( test_cli20 . end_url ( ( path % my_id ) , query ) , 'GET' , body = None , headers = mox . ContainsKeyValue ( 'X-Auth-Token' , test_cli20 . TOKEN ) ) . AndReturn ( return_tup ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# cmd_parser = cmd . get_parser ( ( 'test_' + resource ) ) #NEWLINE# parsed_args = cmd_parser . parse_args ( args ) #NEWLINE# cmd . run ( parsed_args ) #NEWLINE# self . mox . VerifyAll ( ) #NEWLINE# self . mox . UnsetStubs ( ) #NEWLINE# _str = self . fake_stdout . make_string ( ) #NEWLINE# self . assertIn ( 'bytes_in' , _str ) #NEWLINE# self . assertIn ( '1234' , _str ) #NEWLINE# self . assertIn ( 'bytes_out' , _str ) #NEWLINE# self . assertIn ( '4321' , _str )