Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 def test_clear(self):
     videocache.init()
     videocache.clear()