Example #1
0
    def generate_thumbnail(self, width, height):
        ev = threading.Event()

        def completion(path):
            ev.set()
            self.assertEqual(path, self.temp_path.name)

        video.get_thumbnail(self.video_path, width, height,
                            self.temp_path.name, completion,
                            skip=0)
        ev.wait(10)
        if not ev.is_set():
            self.assertTrue(None, 'timed out generating thumbnail image')

        thumbnail = video.VideoFile(self.temp_path.name)
        return thumbnail
 def generate_thumbnail(self, width, height):
     path = video.get_thumbnail(self.video_path, width, height,
                                self.temp_path.name,
                                skip=0)
     self.assertEqual(path, self.temp_path.name)
     thumbnail = video.VideoFile(path)
     return thumbnail
Example #3
0
    def generate_thumbnail(self, width, height):
        ev = threading.Event()

        def completion(path):
            ev.set()
            self.assertEqual(path, self.temp_path.name)

        video.get_thumbnail(self.video_path,
                            width,
                            height,
                            self.temp_path.name,
                            completion,
                            skip=0)
        ev.wait(10)
        if not ev.is_set():
            self.assertTrue(None, 'timed out generating thumbnail image')

        thumbnail = video.VideoFile(self.temp_path.name)
        return thumbnail
 def generate_thumbnail(self, width, height):
     completion = mock.Mock()
     with mock.patch('mvc.video.idle_add') as mock_idle_add:
         with mock.patch('threading.Thread') as mock_thread:
             video.get_thumbnail(self.video_path, width, height,
                                 self.temp_path.name, completion,
                                 skip=0)
             # get_thumbnail() creates a thread to create the thumbnail.
             # Run the function for that thread now.
             mock_thread.call_args[1]['target']()
             self.assertEquals(mock_idle_add.call_count, 1)
             # At the end of the thread it uses add_idle() to call the
             # completion function.  Run that now.
             mock_idle_add.call_args[0][0]()
             # Now when we call get_thumbnail() it should return
             # immediately with the thumbnail
             path = completion.call_args[0][0]
             self.assertNotEquals(path, None)
             return video.VideoFile(path)
 def generate_thumbnail(self, width, height):
     completion = mock.Mock()
     with mock.patch('mvc.video.idle_add') as mock_idle_add:
         with mock.patch('threading.Thread') as mock_thread:
             video.get_thumbnail(self.video_path,
                                 width,
                                 height,
                                 self.temp_path.name,
                                 completion,
                                 skip=0)
             # get_thumbnail() creates a thread to create the thumbnail.
             # Run the function for that thread now.
             mock_thread.call_args[1]['target']()
             self.assertEquals(mock_idle_add.call_count, 1)
             # At the end of the thread it uses add_idle() to call the
             # completion function.  Run that now.
             mock_idle_add.call_args[0][0]()
             # Now when we call get_thumbnail() it should return
             # immediately with the thumbnail
             path = completion.call_args[0][0]
             self.assertNotEquals(path, None)
             return video.VideoFile(path)