-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_basic_functionality.py
More file actions
166 lines (132 loc) · 4.93 KB
/
test_basic_functionality.py
File metadata and controls
166 lines (132 loc) · 4.93 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python3
"""
Basic functionality test for Machine Learning Model Maker
Tests core components without requiring actual data or GUI display
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
def test_imports():
"""Test that all modules can be imported successfully"""
try:
import data_fetch
print("+ Data fetch module imported successfully")
import data_processing1
print("+ Data processing1 module imported successfully")
import data_processing2
print("+ Data processing2 module imported successfully")
import model_development
print("+ Model development module imported successfully")
import backtest
print("+ Backtest module imported successfully")
import shap_model_development
print("+ SHAP model development module imported successfully")
import gui
print("+ GUI module imported successfully")
return True
except Exception as e:
print(f"- Import failed: {e}")
return False
def test_configuration():
"""Test configuration loading"""
try:
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
# Check required sections exist
required_sections = ['API', 'csv_directory', 'Paths', 'Model', 'Training']
for section in required_sections:
if section not in config:
print(f"- Missing section: {section}")
return False
# Check required keys exist
required_keys = {
'Paths': ['loading_path', 'saving_path', 'loading_path2', 'saving_path2'],
'Model': ['target_column'],
'Training': ['test_size', 'scaler_type']
}
for section, keys in required_keys.items():
for key in keys:
if key not in config[section]:
print(f"- Missing key {section}.{key}")
return False
print("+ Configuration file loaded and validated successfully")
return True
except Exception as e:
print(f"- Configuration test failed: {e}")
return False
def test_core_functions():
"""Test core function availability"""
try:
from model_development import (
preprocess_data, split_and_scale_data, train_model,
evaluate_model, select_best_model_and_save, process_file
)
print("+ Core ML functions available")
from shap_model_development import perform_shap_analysis
print("+ SHAP analysis function available")
from backtest import backtest_regression
print("+ Backtest function available")
return True
except Exception as e:
print(f"- Core functions test failed: {e}")
return False
def test_data_processing():
"""Test data processing functionality"""
try:
import data_processing1
import data_processing2
# Test that the modules can be imported and don't crash
print("+ Data processing modules functional")
return True
except Exception as e:
print(f"- Data processing test failed: {e}")
return False
def test_gui_components():
"""Test GUI component creation"""
try:
import tkinter as tk
# Test that we can create a basic tkinter window
root = tk.Tk()
root.withdraw() # Hide the window
# Test that the GUI module can be imported and functions exist
from gui import create_gui, main
# Test that the functions are callable
assert callable(create_gui)
assert callable(main)
print("+ GUI components created successfully")
# Clean up
root.destroy()
return True
except Exception as e:
print(f"- GUI test failed: {e}")
return False
def main():
"""Run all tests"""
print("Testing Machine Learning Model Maker Basic Functionality\n")
tests = [
("Import Test", test_imports),
("Configuration Test", test_configuration),
("Core Functions Test", test_core_functions),
("Data Processing Test", test_data_processing),
("GUI Components Test", test_gui_components)
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n--- {test_name} ---")
if test_func():
passed += 1
else:
print(f"- {test_name} FAILED")
print(f"\nTest Results: {passed}/{total} tests passed")
if passed == total:
print("+ All tests passed! Basic functionality is working.")
print("+ Machine Learning Model Maker is ready for beta deployment.")
return True
else:
print("- Some tests failed. Check the output above for details.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)