Files
swingmusic-extended/test_all_integrations.py
Tomas Dvorak cbf646e25b Fix CI/CD pipeline and code quality issues
## Major Changes
- Fixed all TypeScript errors in web client for successful compilation
- Resolved 82+ Python lint errors across backend services
- Updated Flutter SDK compatibility for mobile app
- Fixed security workflow configuration

## Web Client Fixes
- Fixed import path in DragonflyDashboard.vue (dragonflyApi import)
- All TypeScript compilation now passes without errors

## Backend Lint Fixes
- Updated type annotations to modern Python syntax (dict instead of Dict, X | None instead of Optional[X])
- Replaced try-except-pass with contextlib.suppress(Exception)
- Removed unused imports (Dict, Optional, Any, Iterator, etc.)
- Fixed bare except clauses to use Exception
- Sorted and formatted imports with ruff
- Applied ruff format to 27 files

## Workflow Fixes
- Updated Flutter SDK constraint from ^3.10.4 to ^3.5.0 (compatible with Flutter 3.24.0)
- Changed pip-audit format from github to json in security.yml
- Added comprehensive CI workflows (readiness-gate.yml, security.yml)

## Infrastructure
- Added DragonflyDB caching system integration
- Enhanced Docker configuration with multi-stage builds
- Added pytest configuration and test infrastructure
- Improved production readiness with proper error handling

## Verification
- backend-lint job:  Succeeded
- web job:  Succeeded
- Ready for GitHub deployment

All CI/CD issues resolved. Codebase now passes all quality checks.
2026-03-21 10:01:14 +01:00

250 lines
8.3 KiB
Python

#!/usr/bin/env python3
"""
Test all Spotify integration points to ensure they work with the new implementation
"""
import json
import logging
import sys
import os
# Add the src directory to the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
def test_spotify_metadata_client():
"""Test the main SpotifyMetadataClient (used by most services)"""
logger.info("Testing SpotifyMetadataClient...")
try:
from swingmusic.services.spotify_metadata_client import get_spotify_metadata_client
client = get_spotify_metadata_client()
# Test track lookup
track = client.get_track("4cOdK2wGLETOMrsVzAojDx")
if track:
logger.info("✅ SpotifyMetadataClient track lookup: SUCCESS")
else:
logger.error("❌ SpotifyMetadataClient track lookup: FAILED")
return False
# Test album lookup
album = client.get_album("1DFixLWUoKaZYxZkLUKQu9")
if album:
logger.info("✅ SpotifyMetadataClient album lookup: SUCCESS")
else:
logger.error("❌ SpotifyMetadataClient album lookup: FAILED")
return False
# Test playlist lookup
playlist = client.get_playlist("37i9dQZF1DXcBWIGoYBM5M")
if playlist:
logger.info("✅ SpotifyMetadataClient playlist lookup: SUCCESS")
else:
logger.error("❌ SpotifyMetadataClient playlist lookup: FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ SpotifyMetadataClient test failed: {e}")
return False
def test_music_catalog_service():
"""Test MusicCatalogService integration"""
logger.info("Testing MusicCatalogService...")
try:
from swingmusic.services.music_catalog import MusicCatalogService
service = MusicCatalogService()
# Test album details
album = service.get_album_details("1DFixLWUoKaZYxZkLUKQu9")
if album:
logger.info("✅ MusicCatalogService album details: SUCCESS")
else:
logger.error("❌ MusicCatalogService album details: FAILED")
return False
# Test playlist details
playlist = service.get_playlist_details("37i9dQZF1DXcBWIGoYBM5M")
if playlist:
logger.info("✅ MusicCatalogService playlist details: SUCCESS")
else:
logger.error("❌ MusicCatalogService playlist details: FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ MusicCatalogService test failed: {e}")
return False
def test_spotify_downloader():
"""Test Spotify downloader integration"""
logger.info("Testing Spotify downloader...")
try:
from swingmusic.services.spotify_downloader import get_spotify_metadata
# Test track metadata extraction
metadata = get_spotify_metadata("https://open.spotify.com/track/4cOdK2wGLETOMrsVzAojDx")
if metadata:
logger.info("✅ Spotify downloader metadata extraction: SUCCESS")
else:
logger.error("❌ Spotify downloader metadata extraction: FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ Spotify downloader test failed: {e}")
return False
def test_songlink_client():
"""Test Song.link client integration"""
logger.info("Testing Song.link client...")
try:
from swingmusic.services.songlink_client import get_songlink_client
client = get_songlink_client()
# Test cross-platform links
links = client.get_links_from_spotify_id("4cOdK2wGLETOMrsVzAojDx")
if links:
logger.info("✅ Song.link cross-platform links: SUCCESS")
logger.info(f" Available platforms: {list(links.links.keys())}")
else:
logger.error("❌ Song.link cross-platform links: FAILED")
return False
# Test availability checking
availability = client.check_availability("4cOdK2wGLETOMrsVzAojDx")
if availability:
logger.info("✅ Song.link availability check: SUCCESS")
logger.info(f" Tidal available: {availability.tidal}")
logger.info(f" Qobuz available: {availability.qobuz}")
logger.info(f" Amazon available: {availability.amazon}")
else:
logger.error("❌ Song.link availability check: FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ Song.link client test failed: {e}")
return False
def test_url_parsing():
"""Test URL parsing capabilities"""
logger.info("Testing URL parsing...")
try:
from swingmusic.services.universal_url_parser import parse_url
# Test Spotify URL parsing
result = parse_url("https://open.spotify.com/track/4cOdK2wGLETOMrsVzAojDx")
if result and result.get("source") == "spotify":
logger.info("✅ URL parsing (Spotify track): SUCCESS")
else:
logger.error("❌ URL parsing (Spotify track): FAILED")
return False
# Test album URL parsing
result = parse_url("https://open.spotify.com/album/1DFixLWUoKaZYxZkLUKQu9")
if result and result.get("source") == "spotify":
logger.info("✅ URL parsing (Spotify album): SUCCESS")
else:
logger.error("❌ URL parsing (Spotify album): FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ URL parsing test failed: {e}")
return False
def test_api_endpoints():
"""Test API endpoint integration"""
logger.info("Testing API endpoints...")
try:
# Test that API modules can import and use the new client
from swingmusic.api.spotify import get_spotify_client
client = get_spotify_client()
if client:
logger.info("✅ API spotify endpoint integration: SUCCESS")
else:
logger.error("❌ API spotify endpoint integration: FAILED")
return False
return True
except Exception as e:
logger.error(f"❌ API endpoints test failed: {e}")
return False
def main():
"""Test all integration points"""
print("=" * 70)
print("Complete Spotify Integration Test")
print("=" * 70)
tests = [
("SpotifyMetadataClient", test_spotify_metadata_client),
("MusicCatalogService", test_music_catalog_service),
("Spotify Downloader", test_spotify_downloader),
("Song.link Client", test_songlink_client),
("URL Parsing", test_url_parsing),
("API Endpoints", test_api_endpoints),
]
results = {}
for test_name, test_func in tests:
print(f"\n{test_name}")
print("-" * 50)
try:
results[test_name] = test_func()
except Exception as e:
logger.error(f"Test {test_name} failed with exception: {e}")
results[test_name] = False
# Summary
print("\n" + "=" * 70)
print("Integration Test Results Summary")
print("=" * 70)
for test_name, success in results.items():
status = "✅ WORKING" if success else "❌ FAILED"
print(f"{test_name:.<30} {status}")
total_tests = len(results)
passed_tests = sum(results.values())
print(f"\nOverall: {passed_tests}/{total_tests} integrations working")
if passed_tests == total_tests:
print("🎉 All integrations working perfectly!")
print("✅ Spotify to MusicBrainz migration complete!")
print("✅ No Spotify account required!")
print("✅ No Premium subscription needed!")
elif passed_tests > 0:
print("⚠️ Most integrations working, but some issues remain.")
else:
print("❌ Major integration issues need to be resolved.")
print("=" * 70)
return passed_tests == total_tests
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)