#NEWLINE# @ patch ( 'nailgun.statistics.oswl.collector.utils.set_proxy' ) #NEWLINE# @ patch ( 'nailgun.statistics.oswl.collector.helpers.ClientProvider' ) #NEWLINE# @ patch ( 'nailgun.statistics.oswl.collector.helpers.get_info_from_os_resource_manager' ) #NEWLINE# def test_skip_collection_for_errorful_cluster( self , get_info_mock , * _ ) : #NEWLINE# #INDENT# error_cluster_id = self . env . create ( api = False , nodes_kwargs = [ { #NEWLINE# #INDENT# 'roles' : [ 'controller' ] , #NEWLINE# 'online' : False , #NEWLINE# #UNINDENT# } ] , cluster_kwargs = { #NEWLINE# #INDENT# 'name' : 'error' , #NEWLINE# 'status' : consts . CLUSTER_STATUSES . operational , #NEWLINE# #UNINDENT# } ) . id #NEWLINE# normal_cluster_id = self . env . create ( api = False , nodes_kwargs = [ { #NEWLINE# #INDENT# 'roles' : [ 'controller' ] , #NEWLINE# 'online' : True , #NEWLINE# #UNINDENT# } ] , cluster_kwargs = { #NEWLINE# #INDENT# 'name' : 'normal' , #NEWLINE# 'status' : consts . CLUSTER_STATUSES . operational , #NEWLINE# #UNINDENT# } ) . id #NEWLINE# get_info_mock . return_value = self . vms_info #NEWLINE# oswl_collect_once ( consts . OSWL_RESOURCE_TYPES . vm ) #NEWLINE# last_for_error_clsr = OpenStackWorkloadStats . get_last_by ( error_cluster_id , consts . OSWL_RESOURCE_TYPES . vm ) #NEWLINE# self . assertIsNone ( last_for_error_clsr ) #NEWLINE# last_for_normal_clsr = OpenStackWorkloadStats . get_last_by ( get_info_mock , consts . OSWL_RESOURCE_TYPES . vm ) #NEWLINE# self . assertIsNotNone ( last_for_normal_clsr ) #NEWLINE# upd_time = last_for_normal_clsr . updated_time #NEWLINE# res_data = { #NEWLINE# #INDENT# 'added' : [ { #NEWLINE# #INDENT# 'time' : upd_time . isoformat ( ) , #NEWLINE# 'id' : 1 , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'removed' : [ ] , #NEWLINE# 'modified' : [ ] , #NEWLINE# 'current' : self . vms_info , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( last_for_normal_clsr . resource_data , res_data )