-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_solid_refactor.py
More file actions
89 lines (66 loc) · 2.39 KB
/
test_solid_refactor.py
File metadata and controls
89 lines (66 loc) · 2.39 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
#!/usr/bin/env python3
"""
Test script to validate the refactored Donchian Strategy following SOLID principles
"""
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from core.donchian_strategy import (
DonchianStrategy,
StrategyConfig,
)
def test_strategy_instantiation():
"""Test that the strategy can be instantiated without errors"""
print("🔍 Testing Strategy Instantiation...")
try:
strategy = DonchianStrategy()
print("✅ Strategy instantiated successfully")
# Basic validation that key components exist
assert hasattr(strategy, "config"), "StrategyConfig not initialized"
assert hasattr(strategy, "quant_integration"), "QuantitativeIntegration not initialized"
print("✅ Strategy components validated")
return True
except Exception as e:
print(f"❌ Error instantiating strategy: {e}")
return False
def test_strategy_config():
"""Test StrategyConfig instantiation"""
print("\n🔍 Testing StrategyConfig...")
try:
config = StrategyConfig()
print("✅ StrategyConfig instantiated successfully")
# Verify required attributes exist
required_attrs = ["symbol", "timeframe", "period", "risk_percent"]
for attr in required_attrs:
assert hasattr(config, attr), f"Missing attribute: {attr}"
print(f"✅ All required config attributes present: {len(required_attrs)} attributes")
return True
except Exception as e:
print(f"❌ Error testing StrategyConfig: {e}")
return False
def main():
"""Run all tests"""
print("🧪 Testing Refactored Donchian Strategy (SOLID Implementation)")
print("=" * 60)
tests = [
test_strategy_instantiation,
test_strategy_config,
]
results = []
for test in tests:
results.append(test())
print("\n" + "=" * 60)
print("SUMMARY:")
print(f"Total tests: {len(results)}")
print(f"Passed: {sum(results)}")
print(f"Failed: {len(results) - sum(results)}")
if all(results):
print(
"🎉 All tests passed! The refactored strategy follows SOLID principles correctly.",
)
return True
print("❌ Some tests failed. Please review the implementation.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)