Spaces:
Sleeping
Sleeping
File size: 2,810 Bytes
e7cf9be | 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 python3
"""
Simple validation script to test our implementation structure.
"""
def test_config():
"""Test configuration loading."""
try:
from src.utils.config import Config
config = Config()
indices = config.get_indices()
print(f"β Config loaded successfully with {len(indices['indices'])} indices")
return True
except Exception as e:
print(f"β Config test failed: {e}")
return False
def test_models():
"""Test model definitions."""
try:
from src.data.models import MarketData, Base
print("β Models imported successfully")
print(f"β MarketData table: {MarketData.__tablename__}")
return True
except Exception as e:
print(f"β Models test failed: {e}")
return False
def test_file_structure():
"""Test file structure."""
import os
required_files = [
'src/data/__init__.py',
'src/data/models.py',
'src/data/database.py',
'src/data/fetcher.py',
'src/data/storage.py',
'src/utils/__init__.py',
'src/utils/config.py',
'config/indices.json',
'requirements.txt'
]
missing_files = []
for file_path in required_files:
if not os.path.exists(file_path):
missing_files.append(file_path)
if missing_files:
print(f"β Missing files: {missing_files}")
return False
else:
print("β All required files present")
return True
def test_syntax():
"""Test Python syntax."""
import py_compile
import glob
python_files = glob.glob('src/**/*.py', recursive=True)
for file_path in python_files:
try:
py_compile.compile(file_path, doraise=True)
except py_compile.PyCompileError as e:
print(f"β Syntax error in {file_path}: {e}")
return False
print(f"β Syntax check passed for {len(python_files)} Python files")
return True
def main():
"""Run all validation tests."""
print("Running MarketWise validation tests...")
print("=" * 50)
tests = [
("File Structure", test_file_structure),
("Python Syntax", test_syntax),
("Configuration", test_config),
("Models", test_models),
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n{test_name}:")
if test_func():
passed += 1
print("\n" + "=" * 50)
print(f"Validation Results: {passed}/{total} tests passed")
if passed == total:
print("π All validation tests passed!")
return True
else:
print("β Some validation tests failed")
return False
if __name__ == "__main__":
main()
|