#NEWLINE# @ mock . patch ( 'changes.lib.snapshot_garbage_collection.get_current_datetime' ) #NEWLINE# def test_get_relevant_snapshot_images_simple( self , get_current_datetime ) : #NEWLINE# #INDENT# project = self . create_project ( ) #NEWLINE# plan1 = self . create_plan ( project ) #NEWLINE# plan2 = self . create_plan ( project ) #NEWLINE# plan3 = self . create_plan ( project ) #NEWLINE# plan4 = self . create_plan ( project ) #NEWLINE# plan5 = self . create_plan ( project ) #NEWLINE# self . create_step ( plan1 , data = { #NEWLINE# #INDENT# 'cluster' : 'cluster1' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . create_step ( plan2 , data = { #NEWLINE# #INDENT# 'cluster' : 'cluster1' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . create_step ( plan3 , data = { #NEWLINE# #INDENT# 'cluster' : 'cluster2' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . create_step ( plan4 , data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . create_step ( plan5 ) #NEWLINE# snapshot = self . create_snapshot ( project ) #NEWLINE# snapshot_image1 = self . create_snapshot_image ( snapshot , plan1 ) #NEWLINE# snapshot_image2 = self . create_snapshot_image ( snapshot , plan2 ) #NEWLINE# snapshot_image3 = self . create_snapshot_image ( snapshot , plan3 ) #NEWLINE# snapshot_image4 = self . create_snapshot_image ( snapshot , plan4 ) #NEWLINE# snapshot_image5 = self . create_snapshot_image ( snapshot , plan5 ) #NEWLINE# get_current_datetime . return_value = self . mock_datetime #NEWLINE# gc . cache_snapshot ( snapshot ) #NEWLINE# images = gc . get_relevant_snapshot_images ( snapshot . id ) #NEWLINE# assert ( len ( images ) == 2 ) #NEWLINE# assert ( 'cluster1' in images ) #NEWLINE# assert ( 'cluster2' in images ) #NEWLINE# assert ( len ( images [ 'cluster1' ] ) == 2 ) #NEWLINE# assert ( snapshot_image1 in images [ 'cluster1' ] ) #NEWLINE# assert ( snapshot_image2 in images [ 'cluster1' ] ) #NEWLINE# assert ( len ( images [ 'cluster2' ] ) == 1 ) #NEWLINE# assert ( snapshot_image3 in images [ 'cluster2' ] )