#NEWLINE# def mock_nova( self ) : #NEWLINE# #INDENT# novaclient_spec = novaclient . Client ( '2' ) #NEWLINE# nova = mock . create_autospec ( novaclient_spec ) #NEWLINE# nova_admin = mock . create_autospec ( novaclient_spec ) #NEWLINE# nova_patcher = mock . patch ( 'novaclient.client.Client' ) #NEWLINE# novaclient_getter = nova_patcher . start ( ) #NEWLINE# self . addCleanup ( nova_patcher . stop ) #NEWLINE# novaclient_getter . side_effect = ( lambda * args , **kwargs : ( nova_admin if ( kwargs . get ( 'session' ) == mock . sentinel . admin_session ) else ( nova if ( kwargs . get ( 'session' ) == mock . sentinel . session ) else None ) ) ) #NEWLINE# return ( nova , nova )