-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_basic.py
More file actions
120 lines (96 loc) · 3.64 KB
/
Copy pathtest_basic.py
File metadata and controls
120 lines (96 loc) · 3.64 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
"""Basic test to verify core functionality without circular imports."""
import sys
import os
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def test_imports():
"""Test basic imports without circular dependencies."""
try:
# Test basic Python imports
import pandas as pd
import numpy as np
print("✓ Basic dependencies imported successfully")
# Test config manager
from core.config_manager import ConfigManager
print("✓ ConfigManager imported successfully")
# Test individual tools without data manager dependencies
print("\nTesting tool imports...")
# Test if we can import tools individually
try:
from tools.technical_analysis_tool import TechnicalAnalysisTool
print("✓ TechnicalAnalysisTool imported successfully")
except Exception as e:
print(f"✗ TechnicalAnalysisTool import failed: {e}")
try:
from tools.news_analysis_tool import NewsAnalysisTool
print("✓ NewsAnalysisTool imported successfully")
except Exception as e:
print(f"✗ NewsAnalysisTool import failed: {e}")
return True
except Exception as e:
print(f"✗ Import test failed: {e}")
return False
def test_basic_functionality():
"""Test basic functionality without external dependencies."""
try:
import pandas as pd
import numpy as np
# Test pandas operations
df = pd.DataFrame({
'price': [100, 101, 102, 101, 103],
'volume': [1000, 1100, 900, 1200, 800]
})
# Basic technical analysis calculations
df['sma_3'] = df['price'].rolling(window=3).mean()
df['returns'] = df['price'].pct_change()
print("✓ Basic pandas operations successful")
print(f" Sample data shape: {df.shape}")
print(f" SMA calculation: {df['sma_3'].iloc[-1]:.2f}")
return True
except Exception as e:
print(f"✗ Basic functionality test failed: {e}")
return False
def test_config_loading():
"""Test configuration loading."""
try:
from core.config_manager import ConfigManager
# Try to load config
config_path = Path("config")
if config_path.exists():
config_manager = ConfigManager(config_path)
print("✓ Config manager initialized successfully")
return True
else:
print("⚠ Config directory not found, skipping config test")
return True
except Exception as e:
print(f"✗ Config loading test failed: {e}")
return False
if __name__ == "__main__":
print("Running basic functionality tests...\n")
tests = [
("Import Tests", test_imports),
("Basic Functionality", test_basic_functionality),
("Config Loading", test_config_loading)
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n=== {test_name} ===")
if test_func():
passed += 1
print(f"✓ {test_name} PASSED")
else:
print(f"✗ {test_name} FAILED")
print(f"\n=== SUMMARY ===")
print(f"Tests passed: {passed}/{total}")
print(f"Success rate: {passed/total*100:.1f}%")
if passed == total:
print("🎉 All basic tests passed!")
sys.exit(0)
else:
print("❌ Some tests failed")
sys.exit(1)