#NEWLINE# @ mock . patch ( 'random.shuffle' ) #NEWLINE# @ mock . patch ( 'time.sleep' ) #NEWLINE# @ mock . patch ( 'nova.image.glance._glanceclient_from_endpoint' ) #NEWLINE# def test_default_client_without_retries( self , create_client_mock , sleep_mock , shuffle_mock ) : #NEWLINE# #INDENT# api_servers = [ 'host1:9292' , 'https://host2:9293' , 'http://host3:9294' ] #NEWLINE# client_mock = mock . MagicMock ( ) #NEWLINE# images_mock = mock . MagicMock ( ) #NEWLINE# images_mock . get . side_effect = glanceclient . exc . ServiceUnavailable #NEWLINE# type ( client_mock ) . images = mock . PropertyMock ( return_value = images_mock ) #NEWLINE# create_client_mock . return_value = client_mock #NEWLINE# shuffle_mock . return_value = api_servers #NEWLINE# self . flags ( num_retries = 0 , group = 'glance' ) #NEWLINE# self . flags ( api_servers = api_servers , group = 'glance' ) #NEWLINE# ctx = context . RequestContext ( 'fake' , 'fake' ) #NEWLINE# client = glance . GlanceClientWrapper ( ) #NEWLINE# self . assertRaises ( exception . GlanceConnectionFailed , client . call , ctx , 1 , 'get' , 'meow' ) #NEWLINE# self . assertEqual ( str ( client . api_server ) , 'http://host1:9292' ) #NEWLINE# self . assertFalse ( sleep_mock . called ) #NEWLINE# self . assertRaises ( exception . GlanceConnectionFailed , client . call , ctx , 1 , 'get' , 'meow' ) #NEWLINE# self . assertEqual ( str ( client . api_server ) , 'https://host2:9293' ) #NEWLINE# self . assertFalse ( client_mock . called )