-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_basic_functionality.py
More file actions
130 lines (100 loc) · 3.7 KB
/
test_basic_functionality.py
File metadata and controls
130 lines (100 loc) · 3.7 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
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python3
"""
Basic functionality test for AlphaMatrix.
"""
import sys
import os
# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_common_functions():
"""Test common utility functions."""
print("Testing common utility functions...")
try:
from alphamatrix.common.logging import get_logger, init_logging
from alphamatrix.common.env import clickhouse_config, api_config
from alphamatrix.common.ids import new_run_id
# Test logging
logger = get_logger(__name__)
logger.info("Logging test successful")
# Test environment config
ch_config = clickhouse_config()
api_config_result = api_config()
print(f"✅ ClickHouse config: {ch_config['host']}:{ch_config['port']}")
print(f"✅ API config: max_rows={api_config_result['max_rows']}")
# Test ID generation
run_id = new_run_id()
print(f"✅ Generated run ID: {run_id}")
return True
except Exception as e:
print(f"❌ Common functions test failed: {e}")
return False
def test_api_imports():
"""Test API imports."""
print("\nTesting API imports...")
try:
from alphamatrix.api.app import app
from alphamatrix.api.config import load_config
# Test app import
print(f"✅ FastAPI app imported: {type(app)}")
# Test config loading
config = load_config()
print(f"✅ Config loaded: {len(config)} items")
return True
except Exception as e:
print(f"❌ API imports test failed: {e}")
return False
def test_etl_imports():
"""Test ETL imports."""
print("\nTesting ETL imports...")
try:
from alphamatrix.etl.jobs.backfill_ohlcv import main as backfill_main
from alphamatrix.etl.jobs.incremental_ohlcv import main as incremental_main
from alphamatrix.etl.adapters.yahoo_finance_adapter import YahooFinanceAdapter
from alphamatrix.etl.io.clickhouse_client import ClickHouseClient
print("✅ ETL job modules imported")
print("✅ ETL adapters imported")
print("✅ ETL IO modules imported")
return True
except Exception as e:
print(f"❌ ETL imports test failed: {e}")
return False
def test_test_imports():
"""Test test module imports."""
print("\nTesting test module imports...")
try:
import alphamatrix.api.tests
import alphamatrix.etl.tests
print("✅ API tests package imported")
print("✅ ETL tests package imported")
# Test specific test modules
from alphamatrix.api.tests.test_app_import import test_imports_ok
from alphamatrix.etl.tests.test_imports import test_etl_imports
print("✅ Test functions imported")
return True
except Exception as e:
print(f"❌ Test imports test failed: {e}")
return False
def main():
print("AlphaMatrix Basic Functionality Test")
print("=" * 50)
tests = [
test_common_functions,
test_api_imports,
test_etl_imports,
test_test_imports,
]
success_count = 0
total_count = len(tests)
for test_func in tests:
if test_func():
success_count += 1
print("\n" + "=" * 50)
print(f"Results: {success_count}/{total_count} tests passed")
if success_count == total_count:
print("🎉 All tests passed!")
return 0
else:
print("❌ Some tests failed!")
return 1
if __name__ == "__main__":
sys.exit(main())