File size: 6,944 Bytes
a963d65 |
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
#!/usr/bin/env python3
"""
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", # Modal production deployment
"deploy_local.py", # Local development deployment
"README.md" # Main documentation
]
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:
# Check main README exists
assert os.path.exists("README.md"), "Main README.md not found"
print("β
Main README.md exists")
# Check that modal/README.md was removed
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)")
# Check README content is comprehensive
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:
# Check for .env file
env_file = ".env"
if os.path.exists(env_file):
print("β
.env file found")
# Read and check for Modal configuration
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)")
# Test environment variable loading
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:
# Files that should NOT exist (cleaned up)
removed_files = [
"modal/README.md", # Should be consolidated into main README
]
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
# Summary
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) |