import os import sys from pathlib import Path # Add the parent directory to the Python path so we can import songify sys.path.insert(0, str(Path(__file__).parent.parent)) from songify import download_video_from_tiktok, download_video_from_s3, upload_video_to_s3 def test_download_video_from_tiktok(): """ test downloading video from tiktok to local file system """ url = "https://www.tiktok.com/@miryummi/video/7532607674991512862" out_dir = "downloads/tiktok" video_path = download_video_from_tiktok(url, out_dir) assert video_path is not None assert os.path.exists(video_path) def test_upload_video_to_s3(): """ test uploading video from local file system to s3, must be run consecutively with test_download_video_from_tiktok to guarantee local file exists """ upload_from_path = "downloads/tiktok/7532607674991512862.mp4" s3_key = "songify/7532607674991512862.mp4" s3_url = upload_video_to_s3(upload_from_path, s3_key) print(s3_url) assert s3_url.startswith("https://cdn1.suno.ai/") assert s3_url.endswith(s3_key) def test_download_video_from_s3(): """ test downloading video from s3 to local file system """ s3_file_name = "songify/7532607674991512862.mp4" out_dir = "downloads/s3" video_path = download_video_from_s3(s3_file_name, out_dir) assert video_path is not None assert os.path.exists(video_path)