#NEWLINE# @ patch ( 'nailgun.statistics.oswl.collector.time.sleep' , side_effect = StopIteration ) #NEWLINE# @ patch . object ( sys , 'argv' , new = [ '_' , consts . OSWL_RESOURCE_TYPES . vm ] ) #NEWLINE# def test_oswl_is_not_collected_when_stats_collecting_disabled( self , * _ ) : #NEWLINE# #INDENT# collect_func_path = 'nailgun.statistics.oswl.collector.collect' #NEWLINE# must_send_stats_path = 'nailgun.statistics.oswl.collector.MasterNodeSettings.must_send_stats' #NEWLINE# with patch ( must_send_stats_path , return_value = False ) : #NEWLINE# #INDENT# with patch ( collect_func_path ) as collect_mock : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# run_collecting ( ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . assertFalse ( collect_mock . called ) #NEWLINE# #UNINDENT# #UNINDENT# with patch ( must_send_stats_path , return_value = True ) : #NEWLINE# #INDENT# with patch ( collect_func_path ) as collect_mock : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# run_collecting ( ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . assertTrue ( collect_mock . called )