34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import os
|
|
import unittest
|
|
|
|
from src.file_manager import FileManager
|
|
|
|
|
|
class FileManagerTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.file_manager = FileManager()
|
|
self.dir = '<Your file directory>' # replace with your directory
|
|
|
|
def test_download_youtube_audio(self):
|
|
youtube_link = '<Your YouTube link>' # replace with a YouTube link
|
|
filename = f'{self.dir}/audio.mp4'
|
|
self.file_manager.download_youtube_audio(youtube_link, filename)
|
|
self.assertTrue(os.path.exists(filename))
|
|
os.remove(filename) # clean up after test
|
|
|
|
def test_convert_to_wav(self):
|
|
mp4_file = '<Your mp4 filename>' # replace with an MP4 file in your directory
|
|
wav_file = mp4_file.replace('.mp4', '.wav')
|
|
self.file_manager.convert_to_wav(mp4_file, wav_file)
|
|
self.assertTrue(os.path.exists(wav_file))
|
|
os.remove(wav_file) # clean up after test
|
|
|
|
def test_load_local_file(self):
|
|
local_file_path = '<Your mp4 filename>' # replace with a file in your directory
|
|
result_path = self.file_manager.load_local_file(local_file_path)
|
|
self.assertEqual(result_path, local_file_path.replace('.mp4', '.wav'))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|