#NEWLINE# @ mock . patch ( ( '%s.sahara_cluster.utils.SaharaScenario._launch_cluster' % CTX ) , return_value = mock . MagicMock ( id = 42 ) ) #NEWLINE# def test_setup_and_cleanup_error( self , mock_sahara_scenario__launch_cluster ) : #NEWLINE# #INDENT# sahara_ctx = sahara_cluster . SaharaCluster ( self . context ) #NEWLINE# launch_cluster_calls = [ ] #NEWLINE# for i in self . tenants : #NEWLINE# #INDENT# launch_cluster_calls . append ( mock . call ( flavor_id = None , plugin_name = 'test_plugin' , hadoop_version = 'test_version' , master_flavor_id = 'test_flavor_m' , worker_flavor_id = 'test_flavor_w' , workers_count = 2 , image_id = self . context [ 'tenants' ] [ i ] [ 'sahara' ] [ 'image' ] , floating_ip_pool = None , volumes_per_node = None , volumes_size = 1 , auto_security_groups = True , security_groups = None , node_configs = None , cluster_configs = None , wait_active = False ) ) #NEWLINE# #UNINDENT# self . clients ( 'sahara' ) . clusters . get . side_effect = [ mock . MagicMock ( status = 'not-active' ) , mock . MagicMock ( status = 'error' ) ] #NEWLINE# self . assertRaises ( exceptions . SaharaClusterFailure , sahara_ctx . setup )