Exemplo n.º 1
0
 def test_throw_terminal_exception_on_bad_video(self):
     try:
         Undertest.extract_audio("bad_video_file_path", True, 16000)
     except Exception as e:
         self.assertTrue(isinstance(e, TerminalException))
         self.assertFalse(os.path.exists("bad_video_file_path.mp4.wav"))
     else:
         self.fail("Should have thrown exception")
Exemplo n.º 2
0
 def test_throw_exception_on_vtt2srt_exception(self, mock_communicate):
     try:
         Undertest.extract_audio(self.__video_file_path)
     except Exception as e:
         self.assertTrue(mock_communicate.called)
         self.assertTrue(isinstance(e, TerminalException))
         self.assertTrue("Cannot extract audio from video:" in str(e))
     else:
         self.fail("Should have thrown exception")
Exemplo n.º 3
0
 def test_throw_exception_on_extract_audio_timeout(self, mock_communicate):
     try:
         Undertest.extract_audio(self.__video_file_path)
     except Exception as e:
         self.assertTrue(mock_communicate.called)
         self.assertTrue(isinstance(e, TerminalException))
         self.assertTrue("interrupted" in str(e))
     else:
         self.fail("Should have thrown exception")
Exemplo n.º 4
0
 def test_throw_exception_on_extract_audio_with_error_code(
         self, mock_popen):
     mock_popen.returncode.return_value = 1
     mock_popen.communicate = Mock()
     mock_popen.communicate.return_value = 1
     try:
         Undertest.extract_audio(self.__video_file_path)
     except Exception as e:
         self.assertTrue(mock_popen.communicate.called_with(180))
         self.assertTrue(isinstance(e, TerminalException))
         self.assertTrue("Cannot extract audio from video:" in str(e))
     else:
         self.fail("Should have thrown exception")
Exemplo n.º 5
0
 def test_extract_audio_wav_from_start_to_end(self):
     self.__audio_file_path = Undertest.extract_audio(
         self.__video_file_path, True, 16000)
     segment_path, duration = Undertest.extract_audio_from_start_to_end(
         self.__audio_file_path, "00:00:13,750", "00:00:16,150")
     self.assertTrue(os.path.isfile(segment_path))
     self.__segment_paths.append(segment_path)
     self.assertEqual(2.4, duration)
Exemplo n.º 6
0
 def test_extract_audio_aac(self):
     self.__audio_file_path = Undertest.extract_audio(
         self.__video_file_path)
     self.assertTrue(os.path.isfile(self.__audio_file_path))
Exemplo n.º 7
0
 def test_extract_audio_wav(self):
     self.__audio_file_path = Undertest.extract_audio(
         self.__video_file_path, True, 16000)
     self.assertTrue(os.path.isfile(self.__audio_file_path))