#NEWLINE# @ mock . patch . object ( hardware . GenericHardwareManager , 'get_ipv4_addr' , autospec = True ) #NEWLINE# def test_with_network_interface( self , mock_get_ipv4 , mock_exec , mock_gethostbyname ) : #NEWLINE# #INDENT# self . agent . network_interface = 'em1' #NEWLINE# mock_get_ipv4 . return_value = '1.2.3.4' #NEWLINE# self . agent . set_agent_advertise_addr ( ) #NEWLINE# self . assertEqual ( ( '1.2.3.4' , 9990 ) , self . agent . advertise_address ) #NEWLINE# mock_get_ipv4 . assert_called_once_with ( mock . ANY , 'em1' ) #NEWLINE# self . assertFalse ( mock_gethostbyname . called ) #NEWLINE# self . assertFalse ( mock_gethostbyname . called )