#NEWLINE# @ mock . patch ( 'oslo_utils.timeutils.is_older_than' ) #NEWLINE# @ mock . patch ( 'oslo_utils.timeutils.parse_strtime' ) #NEWLINE# def test_shelved_poll_filters_task_state( self , mock_parse , mock_older ) : #NEWLINE# #INDENT# self . flags ( shelved_offload_time = 1 ) #NEWLINE# mock_older . return_value = True #NEWLINE# instance1 = self . _create_fake_instance_obj ( ) #NEWLINE# instance1 . task_state = task_states . SPAWNING #NEWLINE# instance1 . vm_state = vm_states . SHELVED #NEWLINE# instance1 . host = self . compute . host #NEWLINE# instance1 . system_metadata = { #NEWLINE# #INDENT# 'shelved_at' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# instance1 . save ( ) #NEWLINE# instance2 = self . _create_fake_instance_obj ( ) #NEWLINE# instance2 . task_state = None #NEWLINE# instance2 . vm_state = vm_states . SHELVED #NEWLINE# instance2 . host = self . compute . host #NEWLINE# instance2 . system_metadata = { #NEWLINE# #INDENT# 'shelved_at' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# instance2 . save ( ) #NEWLINE# data = [ ] #NEWLINE# def fake_soi( context , instance , **kwargs ) : #NEWLINE# #INDENT# data . append ( instance . uuid ) #NEWLINE# #UNINDENT# with mock . patch . object ( self . compute , 'shelve_offload_instance' ) as soi : #NEWLINE# #INDENT# soi . side_effect = fake_soi #NEWLINE# self . compute . _poll_shelved_instances ( self . context ) #NEWLINE# self . assertTrue ( soi . called ) #NEWLINE# self . assertEqual ( [ instance2 . uuid ] , data )