Update: Refactored the code

This commit is contained in:
Izaya Orihara
2023-10-06 15:28:26 +02:00
parent b43335400d
commit 0b1c24de2a
11 changed files with 265 additions and 60 deletions
+33
View File
@@ -0,0 +1,33 @@
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()