BuildTheFuture / test_deployment.py
Abs6187's picture
Upload 16 files
e98d661 verified
import os
import sys
from PIL import Image
import numpy as np
def test_imports():
try:
import gradio as gr
import google.generativeai as genai
import cv2
import numpy as np
from PIL import Image
print("βœ… All required imports successful")
return True
except ImportError as e:
print(f"❌ Import failed: {e}")
return False
def test_app_initialization():
try:
from app import NanoBananaApp
app = NanoBananaApp()
print("βœ… App initialization successful")
return True
except Exception as e:
print(f"❌ App initialization failed: {e}")
return False
def test_image_processing():
try:
test_image = Image.new('RGB', (512, 512), color='white')
from app import NanoBananaApp
app = NanoBananaApp()
resized = app._resize_image_if_needed(test_image)
print(f"βœ… Image processing test passed - size: {resized.size}")
return True
except Exception as e:
print(f"❌ Image processing test failed: {e}")
return False
def test_gradio_interface():
try:
from app import demo
print("βœ… Gradio interface created successfully")
return True
except Exception as e:
print(f"❌ Gradio interface test failed: {e}")
return False
def main():
print("πŸ§ͺ Testing Nano Banana Deployment")
print("=" * 40)
tests = [
("Import Test", test_imports),
("App Initialization", test_app_initialization),
("Image Processing", test_image_processing),
("Gradio Interface", test_gradio_interface)
]
passed = 0
for test_name, test_func in tests:
print(f"\n{test_name}:")
if test_func():
passed += 1
print("\n" + "=" * 40)
print(f"Results: {passed}/{len(tests)} tests passed")
if passed == len(tests):
print("πŸŽ‰ All tests passed! Ready for deployment.")
else:
print("⚠️ Some tests failed. Check the issues above.")
return passed == len(tests)
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)