|
|
|
""" |
|
Test: File Organization Structure |
|
Test that our file organization is clean and complete |
|
""" |
|
|
|
import os |
|
import sys |
|
|
|
def test_modal_directory_structure(): |
|
"""Test Modal directory organization""" |
|
print("π Test: Modal Directory Structure") |
|
|
|
try: |
|
modal_dir = "modal" |
|
expected_files = [ |
|
"modal/__init__.py", |
|
"modal/config.py", |
|
"modal/deploy.py", |
|
"modal/functions.py" |
|
] |
|
|
|
for file_path in expected_files: |
|
assert os.path.exists(file_path), f"Missing file: {file_path}" |
|
print(f"β
{file_path}") |
|
|
|
print("β
Modal directory structure complete") |
|
return True |
|
|
|
except Exception as e: |
|
print(f"β Modal directory test failed: {e}") |
|
return False |
|
|
|
def test_deployment_files(): |
|
"""Test deployment files exist""" |
|
print("\nπ Test: Deployment Files") |
|
|
|
try: |
|
deployment_files = [ |
|
"modal/deploy.py", |
|
"deploy_local.py", |
|
"README.md" |
|
] |
|
|
|
for file_path in deployment_files: |
|
assert os.path.exists(file_path), f"Missing deployment file: {file_path}" |
|
print(f"β
{file_path}") |
|
|
|
print("β
All deployment files present") |
|
return True |
|
|
|
except Exception as e: |
|
print(f"β Deployment files test failed: {e}") |
|
return False |
|
|
|
def test_readme_consolidation(): |
|
"""Test that we have only one main README""" |
|
print("\nπ Test: README Consolidation") |
|
|
|
try: |
|
|
|
assert os.path.exists("README.md"), "Main README.md not found" |
|
print("β
Main README.md exists") |
|
|
|
|
|
modal_readme = "modal/README.md" |
|
if os.path.exists(modal_readme): |
|
print("β οΈ modal/README.md still exists (should be removed)") |
|
return False |
|
else: |
|
print("β
modal/README.md removed (correctly consolidated)") |
|
|
|
|
|
with open("README.md", "r") as f: |
|
content = f.read() |
|
|
|
required_sections = [ |
|
"Modal Labs", |
|
"deployment", |
|
"setup" |
|
] |
|
|
|
for section in required_sections: |
|
if section.lower() in content.lower(): |
|
print(f"β
README contains {section} information") |
|
else: |
|
print(f"β οΈ README missing {section} information") |
|
|
|
print("β
README consolidation successful") |
|
return True |
|
|
|
except Exception as e: |
|
print(f"β README consolidation test failed: {e}") |
|
return False |
|
|
|
def test_environment_variables(): |
|
"""Test environment configuration""" |
|
print("\nπ Test: Environment Variables") |
|
|
|
try: |
|
|
|
env_file = ".env" |
|
if os.path.exists(env_file): |
|
print("β
.env file found") |
|
|
|
|
|
with open(env_file, "r") as f: |
|
env_content = f.read() |
|
|
|
modal_vars = [ |
|
"MODAL_TOKEN_ID", |
|
"MODAL_TOKEN_SECRET", |
|
"MODAL_L4_HOURLY_RATE", |
|
"MODAL_PLATFORM_FEE" |
|
] |
|
|
|
for var in modal_vars: |
|
if var in env_content: |
|
print(f"β
{var} configured") |
|
else: |
|
print(f"β οΈ {var} not found in .env") |
|
else: |
|
print("β οΈ .env file not found (expected for deployment)") |
|
|
|
|
|
l4_rate = float(os.getenv("MODAL_L4_HOURLY_RATE", "0.73")) |
|
platform_fee = float(os.getenv("MODAL_PLATFORM_FEE", "15")) |
|
|
|
assert l4_rate > 0, "L4 rate should be positive" |
|
assert platform_fee > 0, "Platform fee should be positive" |
|
|
|
print(f"β
L4 rate: ${l4_rate}/hour") |
|
print(f"β
Platform fee: {platform_fee}%") |
|
|
|
return True |
|
|
|
except Exception as e: |
|
print(f"β Environment variables test failed: {e}") |
|
return False |
|
|
|
def test_file_cleanup(): |
|
"""Test that redundant files were cleaned up""" |
|
print("\nπ Test: File Cleanup") |
|
|
|
try: |
|
|
|
removed_files = [ |
|
"modal/README.md", |
|
] |
|
|
|
cleanup_success = True |
|
for file_path in removed_files: |
|
if os.path.exists(file_path): |
|
print(f"β οΈ {file_path} still exists (should be removed)") |
|
cleanup_success = False |
|
else: |
|
print(f"β
{file_path} properly removed") |
|
|
|
if cleanup_success: |
|
print("β
File cleanup successful") |
|
|
|
return cleanup_success |
|
|
|
except Exception as e: |
|
print(f"β File cleanup test failed: {e}") |
|
return False |
|
|
|
def main(): |
|
"""Run file organization tests""" |
|
print("π Testing File Organization") |
|
print("=" * 50) |
|
|
|
tests = [ |
|
("Modal Directory Structure", test_modal_directory_structure), |
|
("Deployment Files", test_deployment_files), |
|
("README Consolidation", test_readme_consolidation), |
|
("Environment Variables", test_environment_variables), |
|
("File Cleanup", test_file_cleanup) |
|
] |
|
|
|
results = {} |
|
|
|
for test_name, test_func in tests: |
|
try: |
|
result = test_func() |
|
results[test_name] = result |
|
except Exception as e: |
|
print(f"β Test {test_name} crashed: {e}") |
|
results[test_name] = False |
|
|
|
|
|
print("\n" + "=" * 50) |
|
print("π File Organization Results") |
|
print("=" * 50) |
|
|
|
passed = sum(1 for r in results.values() if r) |
|
total = len(results) |
|
|
|
for test_name, result in results.items(): |
|
status = "β
PASS" if result else "β FAIL" |
|
print(f"{test_name}: {status}") |
|
|
|
print(f"\nOverall: {passed}/{total} tests passed") |
|
|
|
if passed == total: |
|
print("π File organization is complete and clean!") |
|
print("\nπ Organization Summary:") |
|
print("β’ Modal functions organized in modal/ directory") |
|
print("β’ Deployment scripts ready: modal/deploy.py & deploy_local.py") |
|
print("β’ Documentation consolidated in main README.md") |
|
print("β’ Environment configuration ready for deployment") |
|
else: |
|
print("β οΈ Some organization issues found.") |
|
|
|
return passed == total |
|
|
|
if __name__ == "__main__": |
|
success = main() |
|
sys.exit(0 if success else 1) |