#NEWLINE# @ mock . patch ( 'changes.lib.snapshot_garbage_collection.get_current_datetime' ) #NEWLINE# def test_recache_existing_cached_snapshot( self , get_current_datetime ) : #NEWLINE# #INDENT# '\n        In some cases we may want to re-cache an existing snapshot that\n        already has an entry in the cache. This should be transparent.\n        ' #NEWLINE# project = self . create_project ( ) #NEWLINE# plan = self . create_plan ( project ) #NEWLINE# snapshot = self . create_snapshot ( project ) #NEWLINE# snapshot_image = self . create_snapshot_image ( snapshot , self ) #NEWLINE# get_current_datetime . return_value = self . mock_datetime #NEWLINE# self . create_cached_snapshot_image ( snapshot_image , expiration_date = ( self . mock_datetime - datetime . timedelta ( 0 , 1 ) ) ) #NEWLINE# gc . cache_snapshot ( snapshot ) #NEWLINE# cached_snapshot_image = CachedSnapshotImage . query . get ( snapshot_image . id ) #NEWLINE# assert ( cached_snapshot_image is not None ) #NEWLINE# assert ( cached_snapshot_image . expiration_date is None ) #NEWLINE# assert ( CachedSnapshotImage . query . count ( ) == 1 )