#NEWLINE# @ mock . patch ( 'wsgiref.simple_server.make_server' , autospec = True ) #NEWLINE# @ mock . patch . object ( hardware . HardwareManager , 'list_hardware_info' ) #NEWLINE# def test_run( self , mocked_list_hardware , wsgi_server_cls ) : #NEWLINE# #INDENT# wsgi_server = wsgi_server_cls . return_value #NEWLINE# wsgi_server . start . side_effect = KeyboardInterrupt ( ) #NEWLINE# self . agent . heartbeater = mock . Mock ( ) #NEWLINE# self . agent . api_client . lookup_node = mock . Mock ( ) #NEWLINE# self . agent . api_client . lookup_node . return_value = { #NEWLINE# #INDENT# 'node' : { #NEWLINE# #INDENT# 'uuid' : 'deadbeef-dabb-ad00-b105-f00d00bab10c' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'heartbeat_timeout' : 300 , #NEWLINE# #UNINDENT# } #NEWLINE# self . agent . run ( ) #NEWLINE# listen_addr = ( '192.0.2.1' , 9999 ) #NEWLINE# wsgi_server_cls . assert_called_once_with ( listen_addr [ 0 ] , listen_addr [ 1 ] , self . agent . api , server_class = simple_server . WSGIServer ) #NEWLINE# wsgi_server . serve_forever . assert_called_once_with ( ) #NEWLINE# self . assertFalse ( wsgi_server_cls . agent . heartbeater . called ) #NEWLINE# self . assertFalse ( self . agent . api_client . lookup_node . called )