def test_get_performance(self):
        videocache.init()
        videocache.clear()

        # Test data.
        # Randomly choose subset of videos.
        videos_sample = random.sample(VIDEOS, 5)

        # Test not cached time.
        for video in videos_sample:
            t0 = timeit.default_timer()
            video_path = videocache.get(video)
            t1 = timeit.default_timer()
            self.assertVideoReady(video_path)
            self.assertOkNotCachedGetTime(t0, t1)

            # Offset downloads.
            time.sleep(2)

        # Test cached time.
        for video in videos_sample:
            t0 = timeit.default_timer()
            video_path = videocache.get(video)
            t1 = timeit.default_timer()
            self.assertVideoReady(video_path)
            self.assertOkCachedGetTime(t0, t1)

            # Offset downloads.
            time.sleep(2)
 def test_clear(self):
     videocache.init()
     videocache.clear()