| """
|
| Test script to verify app.py portability logic
|
| Simulates app.py being in different locations
|
| """
|
|
|
| from pathlib import Path
|
| import sys
|
|
|
| def test_portability_logic(app_location):
|
| """Test the portability logic as if app.py was at app_location"""
|
|
|
|
|
| print(f"\nπ Testing with app.py at: {app_location}")
|
| print("-" * 60)
|
|
|
|
|
| webapp_parent = app_location.parent.parent
|
| if (webapp_parent / 'config').exists():
|
| PROJECT_ROOT = webapp_parent
|
| location_type = "Original location (webapp/)"
|
| else:
|
|
|
| PROJECT_ROOT = app_location.parent
|
| while PROJECT_ROOT != PROJECT_ROOT.parent:
|
| if (PROJECT_ROOT / 'config').exists() and (PROJECT_ROOT / 'src').exists():
|
| break
|
| PROJECT_ROOT = PROJECT_ROOT.parent
|
| location_type = "Moved location (outside webapp/)"
|
|
|
|
|
| WEBAPP_FOLDER = PROJECT_ROOT / 'webapp'
|
|
|
|
|
| print(f"Location type: {location_type}")
|
| print(f"PROJECT_ROOT: {PROJECT_ROOT}")
|
| print(f"WEBAPP_FOLDER: {WEBAPP_FOLDER}")
|
|
|
|
|
| required_folders = ['config', 'src', 'webapp', 'ai_models', 'docs']
|
| all_exist = True
|
| print(f"\nRequired folders check:")
|
| for folder in required_folders:
|
| exists = (PROJECT_ROOT / folder).exists()
|
| status = "β" if exists else "β"
|
| print(f" {status} {folder}")
|
| all_exist = all_exist and exists
|
|
|
|
|
| print(f"\nFlask folders check:")
|
| templates_exist = (WEBAPP_FOLDER / 'templates').exists()
|
| static_exist = (WEBAPP_FOLDER / 'static').exists()
|
| print(f" {'β' if templates_exist else 'β'} templates/")
|
| print(f" {'β' if static_exist else 'β'} static/")
|
|
|
| return all_exist and templates_exist and static_exist
|
|
|
|
|
| project_root = Path(__file__).parent
|
| result1 = test_portability_logic(project_root / 'webapp' / 'app.py')
|
|
|
|
|
| result2 = test_portability_logic(project_root / 'app.py')
|
|
|
|
|
| result3 = test_portability_logic(project_root / 'src' / 'app.py')
|
|
|
|
|
| print("\n" + "=" * 60)
|
| print("PORTABILITY TEST SUMMARY")
|
| print("=" * 60)
|
| print(f"β Original location (webapp/app.py): {'PASS' if result1 else 'FAIL'}")
|
| print(f"{'β' if result2 else 'β'} Moved to root (app.py): {'PASS' if result2 else 'FAIL'}")
|
| print(f"{'β' if result3 else 'β'} Moved to src (src/app.py): {'PASS' if result3 else 'FAIL'}")
|
|
|
| if result1 and result2 and result3:
|
| print("\nβ
app.py IS PORTABLE - Can be used anywhere in the project!")
|
| else:
|
| print("\nβ app.py is NOT fully portable")
|
|
|