-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_setup.py
More file actions
105 lines (82 loc) · 2.92 KB
/
test_setup.py
File metadata and controls
105 lines (82 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python
"""
Quick test script to verify the setup works.
Run this with: python test_setup.py
"""
import os
import sys
def test_imports():
"""Test that all imports work."""
print("Testing imports...")
try:
import fundas as fd
print("✓ fundas imported successfully")
import pandas as pd
print("✓ pandas imported")
import requests
print("✓ requests imported")
from PyPDF2 import PdfReader
print("✓ PyPDF2 imported")
from PIL import Image
print("✓ Pillow imported")
from bs4 import BeautifulSoup
print("✓ beautifulsoup4 imported")
import cv2
print("✓ opencv-python imported")
from dotenv import load_dotenv
print("✓ python-dotenv imported")
return True
except ImportError as e:
print(f"✗ Import failed: {e}")
return False
def test_env_loading():
"""Test that environment variables are loaded."""
print("\nTesting environment configuration...")
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ.get("OPENROUTER_API_KEY")
model = os.environ.get("OPENROUTER_MODEL")
if api_key:
print(f"✓ OPENROUTER_API_KEY is set (length: {len(api_key)})")
else:
print("⚠ OPENROUTER_API_KEY is not set")
print(" Edit .env file and add your API key")
if model:
print(f"✓ OPENROUTER_MODEL is set: {model}")
else:
print("ℹ OPENROUTER_MODEL not set (will use default: openai/gpt-3.5-turbo)")
return api_key is not None
def test_client_creation():
"""Test creating OpenRouterClient."""
print("\nTesting client creation...")
try:
from fundas.core import OpenRouterClient
# Test with mock API key if real one not available
api_key = os.environ.get("OPENROUTER_API_KEY", "test-key-for-init")
client = OpenRouterClient(api_key=api_key)
print(f"✓ OpenRouterClient created successfully")
print(f" Model: {client.model}")
print(f" Cache enabled: {client.use_cache}")
return True
except Exception as e:
print(f"✗ Client creation failed: {e}")
return False
def main():
print("=" * 60)
print("Fundas Setup Test")
print("=" * 60)
results = []
results.append(test_imports())
results.append(test_env_loading())
results.append(test_client_creation())
print("\n" + "=" * 60)
if all(results):
print("✓ All tests passed! Setup is complete.")
if not os.environ.get("OPENROUTER_API_KEY"):
print("\nNote: Add your OPENROUTER_API_KEY to .env to use the library")
return 0
else:
print("✗ Some tests failed. Please check the errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())