import os from PIL import Image from app import process_image def test_process_image(): # Create a large dummy image large_img_path = "test_large.png" Image.new('RGB', (2000, 2000), color='red').save(large_img_path) # Process it processed_path = process_image(large_img_path) # Check if a new file was created assert processed_path != large_img_path, "Should have returned a new path" assert "cropped" in processed_path, "New path should contain 'cropped'" # Check dimensions with Image.open(processed_path) as img: assert img.size == (1024, 1024), f"Expected 1024x1024, got {img.size}" print("Large image test passed!") # Create a small dummy image small_img_path = "test_small.png" Image.new('RGB', (800, 800), color='blue').save(small_img_path) # Process it processed_path_small = process_image(small_img_path) # Check if it returned the same path assert processed_path_small == small_img_path, "Should have returned original path" print("Small image test passed!") # Cleanup if os.path.exists(large_img_path): os.remove(large_img_path) if os.path.exists(processed_path): os.remove(processed_path) if os.path.exists(small_img_path): os.remove(small_img_path) if __name__ == "__main__": test_process_image()