Abd756/StemSense
0
1import os2import sys3import pytest4 5# Add project root to sys.path6sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))7 8from core.packager import Packager9 10def test_packaging():11 packager = Packager()12 13 # We will use the existing audio file and some dummy metadata14 track_name = "Ek Raat"15 original_file = "e:/Projects/Spotify_Project/data/downloads/Ek Raat - Vilen.mp3"16 17 # Since we haven't run stems yet, we'll create a dummy stems folder for testing18 dummy_stems_dir = os.path.join(os.getcwd(), "data", "dummy_stems")19 os.makedirs(dummy_stems_dir, exist_ok=True)20 21 # Create a dummy file in it22 with open(os.path.join(dummy_stems_dir, "vocals.wav"), "w") as f:23 f.write("dummy audio data")24 25 analysis_data = {26 "bpm": 89.29,27 "key": "E",28 "loudness_lufs": -8.13,29 "processed_at": "2025-12-31"30 }31 32 if not os.path.exists(original_file):33 pytest.skip("No original file to package. Run downloader first.")34 35 zip_path = packager.create_package(track_name, original_file, dummy_stems_dir, analysis_data)36 37 assert zip_path is not None38 assert os.path.exists(zip_path)39 assert zip_path.endswith(".zip")40 41 print(f"\n--- Packager Test Successful ---")42 print(f"ZIP File: {zip_path}")43 44 # Cleanup dummy data45 os.remove(os.path.join(dummy_stems_dir, "vocals.wav"))46 os.rmdir(dummy_stems_dir)47 48if __name__ == "__main__":49 test_packaging()50 