Spaces:
Sleeping

marketwise / validate_implementation.py
MikeZhang69
Configure HF Spaces: LFS for db, ignore venv
e7cf9be
Raw History Blame Contribute Delete
2.81 kB
#!/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()