#NEWLINE# def test_clean_expired_entries( self ) : #NEWLINE# #INDENT# dt_now = datetime . datetime . utcnow ( ) #NEWLINE# t_delta = datetime . timedelta ( days = settings . OSWL_STORING_PERIOD ) #NEWLINE# entries_to_del_cluster_ids = ( 1 , 2 ) #NEWLINE# for cluster_id in entries_to_del_cluster_ids : #NEWLINE# #INDENT# obj_kwargs = { #NEWLINE# #INDENT# 'cluster_id' : cluster_id , #NEWLINE# 'resource_type' : consts . OSWL_RESOURCE_TYPES . volume , #NEWLINE# 'updated_time' : dt_now . time ( ) , #NEWLINE# 'created_date' : ( dt_now . date ( ) - t_delta ) , #NEWLINE# 'resource_checksum' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# OpenStackWorkloadStats . create ( obj_kwargs ) #NEWLINE# #UNINDENT# untouched_obj_kwargs = { #NEWLINE# #INDENT# 'cluster_id' : 3 , #NEWLINE# 'resource_type' : consts . OSWL_RESOURCE_TYPES . vm , #NEWLINE# 'updated_time' : dt_now . time ( ) , #NEWLINE# 'created_date' : dt_now . date ( ) , #NEWLINE# 'resource_checksum' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# OpenStackWorkloadStats . create ( untouched_obj_kwargs ) #NEWLINE# OpenStackWorkloadStatsCollection . clean_expired_entries ( ) #NEWLINE# self . db . commit ( ) #NEWLINE# for cluster_id in entries_to_del_cluster_ids : #NEWLINE# #INDENT# instance = OpenStackWorkloadStats . get_last_by ( cluster_id , consts . OSWL_RESOURCE_TYPES . volume ) #NEWLINE# self . assertIsNone ( instance ) #NEWLINE# #UNINDENT# untouched_obj = OpenStackWorkloadStats . get_last_by ( untouched_obj_kwargs [ 'cluster_id' ] , consts . OSWL_RESOURCE_TYPES . vm ) #NEWLINE# self . assertIsNotNone ( untouched_obj )