Spaces:
Running
Running
Create test_supabase.py
Browse files- tests/test_supabase.py +46 -0
tests/test_supabase.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Add src to path
|
| 6 |
+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
| 7 |
+
|
| 8 |
+
from src.supabase_integration import SupabaseIntegration
|
| 9 |
+
|
| 10 |
+
class TestSupabaseIntegration:
|
| 11 |
+
"""Test Supabase integration"""
|
| 12 |
+
|
| 13 |
+
def setup_method(self):
|
| 14 |
+
"""Setup test fixtures"""
|
| 15 |
+
self.supabase = SupabaseIntegration("test_url", "test_key")
|
| 16 |
+
|
| 17 |
+
def test_get_music_context(self):
|
| 18 |
+
"""Test music context retrieval"""
|
| 19 |
+
context = self.supabase.get_music_context("test query")
|
| 20 |
+
|
| 21 |
+
assert isinstance(context, dict)
|
| 22 |
+
assert "songs" in context
|
| 23 |
+
assert "artists" in context
|
| 24 |
+
assert "stats" in context
|
| 25 |
+
assert "summary" in context
|
| 26 |
+
|
| 27 |
+
def test_generate_summary(self):
|
| 28 |
+
"""Test summary generation"""
|
| 29 |
+
context = {
|
| 30 |
+
"stats": {"song_count": 100, "artist_count": 10, "user_count": 1000},
|
| 31 |
+
"songs": [{"title": "Test Song", "artist": "Test Artist"}],
|
| 32 |
+
"artists": [{"name": "Test Artist"}]
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
summary = self.supabase.generate_summary(context, "test query")
|
| 36 |
+
assert isinstance(summary, str)
|
| 37 |
+
assert len(summary) > 0
|
| 38 |
+
|
| 39 |
+
def test_fallback_context(self):
|
| 40 |
+
"""Test fallback context"""
|
| 41 |
+
context = self.supabase.get_fallback_context()
|
| 42 |
+
assert isinstance(context, dict)
|
| 43 |
+
assert "summary" in context
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
pytest.main([__file__])
|