54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
import unittest
|
|
import os
|
|
from litellm_dashboard import Tools
|
|
|
|
INTEGRATION_KEY_PATH = "/tmp/litellm-integration-testing-key.txt"
|
|
LIVE_URL = "http://mon-serv1.captcouch.xyz:4001"
|
|
|
|
class TestLiteLLMToolConsolidated(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.tools = Tools()
|
|
cls.tools.valves.litellm_url = LIVE_URL
|
|
if os.path.exists(INTEGRATION_KEY_PATH):
|
|
with open(INTEGRATION_KEY_PATH, 'r') as f:
|
|
cls.tools.valves.litellm_master_key = f.read().strip()
|
|
|
|
def test_litellm_status(self):
|
|
"""Test consolidated infrastructure + model health check."""
|
|
output = self.tools.litellm_status()
|
|
print("\n--- Status Output ---")
|
|
print(output)
|
|
self.assertIn("Infrastructure Status", output)
|
|
self.assertIn("Proxy: ✅", output)
|
|
self.assertIn("healthy", output.lower())
|
|
|
|
def test_litellm_usage_summary(self):
|
|
"""Test token-efficient usage snapshot."""
|
|
output = self.tools.litellm_usage(detail_level="summary")
|
|
print("\n--- Usage Summary ---")
|
|
print(output)
|
|
self.assertIn("Spend Summary", output)
|
|
self.assertIn("Total Lifetime Spend", output)
|
|
|
|
def test_litellm_usage_full(self):
|
|
"""Test detailed fiscal report with sparklines."""
|
|
output = self.tools.litellm_usage(start_date="7 days ago", detail_level="full")
|
|
print("\n--- Usage Full ---")
|
|
print(output)
|
|
self.assertIn("Usage Report", output)
|
|
self.assertIn("Breakdown by Endpoint", output)
|
|
|
|
def test_litellm_history_filtered(self):
|
|
"""Test filtered request history."""
|
|
output = self.tools.litellm_history(limit=5, filter_model="gemini")
|
|
print("\n--- History Output ---")
|
|
print(output)
|
|
self.assertIn("History", output)
|
|
# Verify filtering if logs exist
|
|
if "gemini" in output.lower():
|
|
self.assertTrue(True)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|