@mock.patch('changes.lib.snapshot_garbage_collection.get_current_datetime')
    def test_recache_existing_cached_snapshot(self, get_current_datetime):
        project = self.create_project()
        plan = self.create_plan(project)
        snapshot = self.create_snapshot(project)
        snapshot_image = self.create_snapshot_image(snapshot, plan)

        get_current_datetime.return_value = self.mock_datetime

        self.create_cached_snapshot_image(snapshot_image,
            expiration_date=self.mock_datetime - datetime.timedelta(0, 1))
        gc.cache_snapshot(snapshot)

        # The old snapshot now has no expiration
        cached_snapshot_image = CachedSnapshotImage.query.get(snapshot_image.id)
        assert cached_snapshot_image is not None
        assert cached_snapshot_image.expiration_date is None

        # and is the only snapshot in existence
        assert CachedSnapshotImage.query.count() == 1
In some cases we may want to re-cache an existing snapshot that
dataset/ETHPy150Open dropbox/changes/tests/changes/lib/test_snapshot_garbage_collection.py/TestSnapshotGCTestCase.test_recache_existing_cached_snapshot